schemedoc / surveys

Scheme Surveys
https://docs.scheme.org/surveys/
MIT License
8 stars 3 forks source link

Add threads survey #17

Open lassik opened 2 years ago

lassik commented 2 years ago

https://doc.scheme.org/surveys/threads/

jpellegrini commented 2 years ago

Guile uses pthreads:

$ ldd /usr/local/bin/guile|grep thread
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f6c4c2b8000)

And implements SRFI-18, plus some extra procedures: https://www.gnu.org/software/guile/manual/guile.html#Scheduling

jpellegrini commented 2 years ago

Bigloo supports SRFI-18 https://www-sop.inria.fr/mimosa/fp/Bigloo/manual.html and uses pthreads . It also implements fair cooperative threads: https://www-sop.inria.fr/mimosa/fp/Bigloo/manual-chapter16.html

aoh commented 2 years ago

Co-operative multitasking is used in coroutines. Schemes with virtual threads usually implement some form of preemptive multitasking.

shirok commented 2 years ago

Gauche uses Windows threads on MinGW version as well. What qualifies "Re-entrant interpreter"?

lassik commented 2 years ago

Thanks a lot for the feedback!

Added Guile and Bigloo.

Co-operative multitasking is used in coroutines. Schemes with virtual threads usually implement some form of preemptive multitasking.

Confusing wording on my part: the OS threads cooperate to preempt the virtual threads.

However, at least Bigloo's Fair Threads require co-operation to be implemented by user code, so it's doubly cooperative.

What qualifies "Re-entrant interpreter"?

Also confusing wording. "Multiple interpreters per OS process" would be clearer.

Basically, the whole interpreter state is contained in a C struct, allowing the C programmer to create a separate interpreter for each C thread if he so chooses. So the interpreter doesn't need any provisions for multi-threading, but also doesn't get in the way of the C programmer's multi-threading. An interpreter that keeps state in global variables is not re-entrant in this way. TinyScheme and s7 ought to be re-entrant, and Guile is probably close enough. Can one process host multiple independent embedded Gauche's?

siiky commented 2 years ago

Hey, nice initiative!

Maybe I'm misunderstanding something, but what is a "virtual machine" thread? In the case of implementations that don't have a "virtual machine" (a la JVM and BEAM), is that the "main thread" of the program?

The table seems to me to suggest that CHICKEN supports OS threads with the SRFI-18 API, but that's not the case (at least not OOB). The threads provided by the SRFI-18 egg are green threads (please forgive and correct me if this is not the correct/exact terminology). I believe there's an egg that makes it easier to use pthreads, however.

So, shouldn't CHICKEN have "No" in "OS threads"? I'm not sure about the "Virtual threads" part...

shirok commented 2 years ago

Basically, the whole interpreter state is contained in a C struct, allowing the C programmer to create a separate interpreter for each C thread if he so chooses. So the interpreter doesn't need any provisions for multi-threading, but also doesn't get in the way of the C programmer's multi-threading. An interpreter that keeps state in global variables is not re-entrant in this way. TinyScheme and s7 ought to be re-entrant, and Guile is probably close enough. Can one process host multiple independent embedded Gauche's?

Ah, I see. Then Gauche is "no", for some global environments are shared process-wide.