#fork and deterministic resumption of the resulting process
nicolas cellier
ncellier at ifrance.com
Fri Feb 8 01:24:03 UTC 2008
Mathieu Suen a écrit :
>
> On Feb 8, 2008, at 12:19 AM, John Brant wrote:
>
>> [| queue |
>> queue := SharedQueue new.
>> [queue nextPut: 3] forkAt: Processor lowestPriority.
>> queue nextPut: 1.
>> [queue nextPut: 2] fork.
>> (Delay forSeconds: 1) wait. "Hack to let the blocks finish"
>> (Array
>> with: queue next
>> with: queue next
>> with: queue next) inspect] forkAt: Processor lowestPriority + 1
>
> I am confused why the first fork run before the second fork with the
> Andreas patch?
>
> Mth
>
Because of the helperProcess trick.
Draw a stack of process (FIFO) for each priority.
(next put: 3) is added on FIFO of priority 0.
(nextPut: 2) is at priority 1, but it is not added immediately.
The helpProcess that launch it is added at priority 0, therefore after
(nextPut: 3).
So 1 is added to the list, then 3 (unless interrupted by higher priority
- 0.01%), then helperProcess does start (nextPut: 2), and 2 is finally
added...
Nicolas
More information about the Squeak-dev
mailing list
|