July 7th Tuesday (七月 七日 火曜日)
2009-07-16 16:11
281 查看
Threads
Scheme supports multiple threads of evaluation. Threads run concurrently, in the sense that one thread can preempt
another without its cooperation, but threads currently all run on the same processor (i.e., the same underlying OS process
and thread).
Threads are created explicitly by functions such as thread. In terms of the evaluation model, each step in evaluation
actually consists of multiple concurrent expressions, up to one per thread, rather than a single expression. The expressions
all share the same objects and top-level variables, so that they can communicate through shared state. Most evaluation steps
involve a single step in a single expression, but certain synchronization primitives require multiple threads to progress
together in one step.
In addition to the state that is shared among all threads, each thread has its own private state that is accessed through
thread cells. A thread cell is similar to a normal mutable object, but a change to the value inside a thread cell is seen only
when extracting a value from the cell from the same thread. A thread cell can be preserved; when a new thread is created,
the creating thread's value for a preserved thread cell serves as the initial value for the cell in the created thread.
For a non-preserved thread cell, a new thread sees the same initial value (specified when the thread cell is created) as
all other threads.
Scheme supports multiple threads of evaluation. Threads run concurrently, in the sense that one thread can preempt
another without its cooperation, but threads currently all run on the same processor (i.e., the same underlying OS process
and thread).
Threads are created explicitly by functions such as thread. In terms of the evaluation model, each step in evaluation
actually consists of multiple concurrent expressions, up to one per thread, rather than a single expression. The expressions
all share the same objects and top-level variables, so that they can communicate through shared state. Most evaluation steps
involve a single step in a single expression, but certain synchronization primitives require multiple threads to progress
together in one step.
In addition to the state that is shared among all threads, each thread has its own private state that is accessed through
thread cells. A thread cell is similar to a normal mutable object, but a change to the value inside a thread cell is seen only
when extracting a value from the cell from the same thread. A thread cell can be preserved; when a new thread is created,
the creating thread's value for a preserved thread cell serves as the initial value for the cell in the created thread.
For a non-preserved thread cell, a new thread sees the same initial value (specified when the thread cell is created) as
all other threads.
相关文章推荐
- July 24th Tuesday (七月 二十四日 火曜日)
- 2008 October 7th Tuesday (十月 七日 火曜日)
- August 7th Tuesday (八月 七日 火曜日)
- 2008 July 1st Tuesday (七月 一日 火曜日)
- 2008 July 15th Tuesday (七月 十五日 火曜日)
- April 7th Tuesday (四月 七日 火曜日)
- July 14th Tuesday (七月 十四日 火曜日)
- July 31th Tuesday (七月 三十一日 火曜日)
- 2008 July 7th Monday (七月 七日 月曜日)
- 2008 July 29th Tuesday (七月 二十九日 火曜日)
- 2008 July 8th Tuesday (七月 八日 火曜日)
- 2008 July 22th Tuesday (七月 二十二日 火曜日)
- July 28th Tuesday (七月 二十八日 火曜日)
- July 10th Tuesday (七月 十日 火曜日)
- July 21th Tuesday (七月 二十一日 火曜日)
- July 3th Tuesday (七月 三日 火曜日)
- July 17th Monday (七月 十七日 火曜日)
- July 11th Wednesday (七月 十一日 水曜日)
- September 4th Tuesday (九月 四日 火曜日)
- December 11th Tuesday (十二月 十一日 火曜日)