proj-plbook-plChCoarseProcesses

Table of Contents for Programming Languages: a survey

Chapter : coarse-grained control processes/control flows (threads and processes) :

thread

pthreads

green thread

coroutines, cooperative multitasking vs preemptive

green thread hierarchy

  with greenthreads/coroutines/fibers you can often feasibly have many more concurrent threads than with OS threads.
 e.g. erlang, e.g. http://blog.paralleluniverse.co/post/64210769930/spaceships2

subroutine call

coroutine (synchronous green thread)

  https://en.wikipedia.org/wiki/Fiber_%28computer_science%29

async green thread (a subroutine call or coroutine at the runtime level) could share scoped variables via a saguaro stack the runtime can transform code written like blocking I/O into async I/O by making an async I/O call then yielding the greenthread and not scheduling it again until the async I/O call completes

green process (separate address space, a subroutine call or coroutine at the runtime level) erlang todo are these async?

thread (shared address space, OS scheduler)

process

"The only other languages I know (edit: besides Go) with built-in lightweight thread schedulers are Erlang/Elixir and Haskell, with the former lacking static typing and the latter lacking management-willing-to-use-ability." -- https://togototo.wordpress.com/2015/03/07/fulfilling-a-pikedream-the-ups-of-downs-of-porting-50k-lines-of-c-to-go/

Implementing greenthreads:

fork

and join

forking at the OS level

random interesting stuff on 'fork':

" The autoconf-generated configure can be slow because it executes programs such as a C compiler many times in order to test whether various libraries, header files, and language features are present. This particularly affects Cygwin, which, due to its lack of a native fork system call, may execute configure scripts considerably slower than Linux.[6] "

Variants:

https://en.wikipedia.org/wiki/Copy-on-write#Copy-on-write_in_virtual_memory_management

blockUntil(expr)

the thread blocks until the expression returns True

some languages (eg SPIN Promela) use bare expressions for blocking: when a bare expression, such as 'finish == 2', is encountered, the thread blocks until the expression returns True

---

task

worker

worker pool

deferred task queues