Well Tim and John had mentioned that a given process gets preemited after around 250 ms, maybe the easiest thing is to just ensure the writes take longer, like:
(1 to: 10000) asOrderedCollection do: [ "..."] inBetweenDo: [ "something slow" ]
From: nicolas cellier ncellier@ifrance.com Reply-To: The general-purpose Squeak developers listsqueak-dev@lists.squeakfoundation.org To: squeak-dev@lists.squeakfoundation.org Subject: Re: Multiple processes using #nextPutAll: Date: Sat, 26 May 2007 18:16:26 +0200
Bert Freudenberg a écrit :
On Sat, 26 May 2007 14:12:59 +0200, Damien Cassou wrote:
Thank you for this comments. That was what I was afraid of. Is it possible to have test that will show #nextPutAll: is not protected?
I'm not convinced #nextPutAll: should be atomic. It would mean a consumer cannot start processing queued items before all elements are written. Right now, #nextPutAll: uses #nextPut: which is "protected". Nothing to fix IMHO.
The test to find out whether #nextPutAll: is atomic or not would be to have a higher-priority reader process that reads one element and peeks for the next. If that succeeds, the lower-priority writer process managed to put in more than one element, meaning #nextPutAll: is not atomic. With the current behavior, however, the reader process would be activated as soon as the first element was written and the peek would fail (I mean, answer nil).
- Bert -
I think Damien was trying to prove that nextPutAll: IS NOT atomic.
It can be pre-empted
- if the process explicitely yield (not possible, there is not a yield call
under nextPutAll:)
- if the process is blocked on a Semaphore (could occur if write on
external streams)
- if a higher priority process is unblocked.
But i do not remember: would the Processor give hand to a process of same priority if none of above conditions happen? (based on round-robin or something).
If not, Damien will have to imagine more tricky code creating one of the 3 conditions above to demonstrate the feature.
Nicolas
_________________________________________________________________ Catch suspicious messages before you open themwith Windows Live Hotmail. http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migr...