Critical section lockup -djb
Ned Konz
ned at bike-nomad.com
Sat Aug 2 01:17:15 UTC 2003
On Friday 01 August 2003 05:07 pm, Derek Brans wrote:
> I have a resource that I only want to be used by one process at a
> time. I've created a ResourceManager class to encapsulate this
> policy.
>
> ResourceManager>>doWithResource: aOneArgumentBlock
> mutexSemaphore critical: [aOneArgumentBlock value: myResource]
>
> Only one process can be using the resource "myResource" at a time.
> Do I have that right?
>
> The problem I have is that if I leave my program running for a few
> days, I invariably find it hung, waiting to execute a critical
> section. I don't see any debugger window popping up, so no error
> was encoutered. Does that mean that one of my blocks that I'm
> passing in is never finishing?
Yes, but not necessarily because it's taking too long to get its work
done.
If you happen to call this from a Process that's already gotten the
semaphore, you'll block that process. Which is probably not what you
want.
You should look at Nathanael's Monitor class; it lets you have
timeouts and not worry about the same Process obtaining the lock
multiple times.
--
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE
More information about the Squeak-dev
mailing list
|