3 ms·
One OS thread per task is not the only way to parallelize a program. If you have a runtime system that allows the creation of light-weight tasks that can be exe
by scott_s 16y ago
One OS thread per task is not the only way to parallelize a program. If you have a runtime system that allows the creation of light-weight tasks that can be executed by pre-existing OS threads, you can exploit very fine grain task parallelism. See The Implementation of the Cilk-5 Multithreaded Language: http://supertech.csail.mit.edu/papers/cilk5.pdf http://supertech.csail.mit.edu/papers/cilk5.pdf
- remogatto 16y agoThat's right. In Go such light-weight tasks are called goroutines. Quoting from Effective Go[1]: A goroutine has a simple model: it is a function executing in parallel with other goroutines in the same address space. It is lightweight, costing little more than the allocation of stack space. And the stacks start small, so they are cheap, and grow by allocating (and freeing) heap storage as required. Goroutines are multiplexed onto multiple OS threads so if one should block, such as while waiting for I/O, others continue to run. Their design hides many of the complexities of thread creation and management. [1] - http://golang.org/doc/effective_go.html#goroutines http://golang.org/doc/effective_go.html#goroutines