[squeak-dev] Suspending process fix

Michael van der Gulik mikevdg at gmail.com
Tue Apr 28 22:00:15 UTC 2009


On 4/28/09, Igor Stasenko <siguctua at gmail.com> wrote:
> Hello, i trying to provide a fix to the issue
> http://bugs.squeak.org/view.php?id=6822
> what is needed to make following code work w/o error:
>
> |sema proc |
> sema := Semaphore new.
> proc := [ sema wait. self error: 'should not be there' ] fork.
> Processor yield.
> proc suspend.
> proc resume.
>
> The problem here, is that once you issue a #suspend on a process it
> puts nil to its myList ivar, ignoring the fact that it could be
> waiting on semaphore.
> This leads to disconnecting the process from semaphore, and any
> subsequent 'sema signal' will be simply lost:
>
> suspend
> 	| oldList |
> 	<primitive: 88>   "primitive will fail, if receiver is not active
> process, which is just our case"
> 	myList ifNil:[^nil].
> 	oldList := myList.
> 	myList := nil.
> 	oldList remove: self ifAbsent:[].
> 	^oldList
>
> the possible fix would be:
> - add an instance variable to Process, say 'semaphore'.

Personally, I'd add an boolean instance variable called "suspended" to
Process, and then modify the scheduler (which unfortunately is in the
VM code) to respect it.

Gulik.

-- 
http://gulik.pbwiki.com/



More information about the Squeak-dev mailing list