Critical sections (was: RE: Lots of concurrency)

Lex Spoon lex at cc.gatech.edu
Thu Oct 25 23:54:21 UTC 2001


> Speaking of critical sections, some dialects of Smalltalk allow you to
> write:
> 
> 	[ balance := balance - 500 ] critical.
> 

Well, the semantics of this are pretty awkward in Smalltalk.  Also, read
some of the recent posts about Java's synchronized keyword -- it might
not be as useful in practice as it looks on a small scale.

However, the following exists and is convenient in Squeak:

  aSemaphore critical: [ balance := balance - 500 ]


Anyway, much better than even this is to rephrase your system in terms
of message passing, as discussed elsewhere in this thread.  Critical
sections are just really tough to work with by hand.


-Lex




More information about the Squeak-dev mailing list