mit-scheme-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MIT-Scheme-devel] Threads in MIT Scheme


From: Aaron Blake Mitchell
Subject: [MIT-Scheme-devel] Threads in MIT Scheme
Date: Sun, 28 Apr 2019 21:08:19 +0000

Hi Prof. Sussman and Leilani,

I have been working solidly on my project for concurrency and actors, however, I have ran into some trouble with threads in MIT Scheme. I have some infrastructure built up in MIT for handling async processes, and I also have working prototypes in Racket, but in MIT Scheme there are some issues with actually launching asynchronous processes.

For MIT Scheme, the only documentation I know of for threads is this (http://web.mit.edu/benmv/6.001/www/threads.txt) and the source for threads, which is located at "master/src/runtime/thread.scm" in the repository. Something relevant is also the "threaded-queue.scm" file.

One problem is that create-thread creates a new thread but blocks until it completes. I prototyped some things in Racket and when calling thread (https://docs.racket-lang.org/reference/threads.html#%28def._%28%28quote._~23~25kernel%29._thread%29%29), that works as I would have expected.

To be more specific:

(define (thunk x) (lambda () x))

In Racket:

(thread (thunk (begin (sleep 2000) (display 2))))

returns immediately with a thread object, and then 2 seconds later displays 2 to the console.

In MIT Scheme,

(create-thread #f (thunk (begin (sleep-current-thread 2000) (display 2))))

blocks until the thread's thunk finishes executing. This is confusing to me, as I cannot figure out how to actually launch a process in a new thread and immediately return to the current thread in MIT Scheme in a non-blocking fashion.

Also, there are quite a few functions in the thread.scm that don't seem to be available in Scheme. Some of them work and some are undefined in a Scheme REPL. For example, create-thread, current-thread, threads-list all work, but run-thread and some others aren't defined. It makes me wonder if I am calling what I think I am calling.

Any thoughts on this? I am basically looking on how to have the functionality found in Racket's thread procedure (linked above). Maybe I am doing something wrong, but I am stuck.

Thank you!
Blake

reply via email to

[Prev in Thread] Current Thread [Next in Thread]