Hi Henrik, Thanks very much for your reply. You wrote: | p x a index first | p := 35. a := Array new: 21. index := 1. first := nil. [ 1 to: 10 do: [ :i | [ first == nil ifTrue: [ first := i. a at: 21 put: first. ]. a at: index put: i. index := index + 1. x := 0. 300000000 timesRepeat: [ x := x + 1 ]. a at: index put: i. index := index + 1. ] forkAt: p named: 'Proc', i asString ]. first == nil ifTrue: [ first := -1. a at: 21 put: first. ]. ] forkAt: p+1. a. Good point, I didn't think this one through properly. And changing both #fork:'s to priority 80 produces the expected: #(1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 -1) So far, so good.
when a process is suspended, it is put to the back of the thread
And this was my misunderstanding. I thought that preempting a process left it at the front of the queue (for its priority). The following produces what I was expecting: | p x a index first | Smalltalk vm processPreemptionYields: false. p := 20. a := Array new: 21. index := 1. first := nil. [ 1 to: 10 do: [ :i | [ first == nil ifTrue: [ first := i. a at: 21 put: first. ]. a at: index put: i. index := index + 1. x := 0. 300000000 timesRepeat: [ x := x + 1 ]. a at: index put: i. index := index + 1. ] forkAt: p named: 'Proc', i asString ]. first == nil ifTrue: [ first := -1. a at: 21 put: first. ]. ] forkAt: p+1. a. Thanks again! Alistair On Mon, 29 Jul 2019 at 12:53, Henrik Sperre Johansen <henrik.s.johansen@veloxit.no> wrote:
Henrik Sperre Johansen wrote
If you remove the suspension point (technically, at:put: is also a suspension point, but let's assume it won't be far enough along in the time slice when the first at:put: happens), and set p high enough that the process won't be interrupted by UI thread (when a process is suspended, it is put to the back of the thread, so you'd still see 1 2 3 4 5 6 7 8 9 10), you get the behaviour you originally expected
( 1 1 2 3 3 4 5 5 6 7 7 8 9 9 10 2 4 6 8 10 -1 ) well, close enough, anyways ;)
Cheers, Henry
-- Sent from: http://forum.world.st/Pharo-Smalltalk-Developers-f1294837.html