home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!rutgers!fdurt1.fdu.edu!wisdom.bubble.org!chsdip!chsdip!groo
- From: groo@chsdip.wisdom.bubble.org (Bill Squier)
- Newsgroups: comp.sys.amiga.programmer
- Subject: LockIBase race condition
- Message-ID: <PfKnr*hX0@chsdip.wisdom.bubble.org>
- Date: 20 Jul 92 19:32:51 GMT
- Organization: Dragonsoft Development
- Lines: 37
- X-Newsreader: Arn V1.00 beta rel2
-
- I've written a small ScreenSwitch commodity to activate the first
- window on the next (or previous) screen. This lets you switch screens
- without "clicking in", and avoids the annoying overhead of
- "AutoPoint"-type commodities. Now keeping in mind the caveat in the
- Autodoc entry for LockIBase ("...This function is not a magic 'fix all
- my race conditions' panacea..." :-) ), I've got a little bit of a race
- condition here:
-
- lock = LockIBase(0);
-
- //
- // Get address of screen we want pushed to back/popped forward
- //
-
- UnlockIBase(lock);
-
- ScreenToFront(); or ScreenToBack(); // <-- race
-
- Now it's understandably unlikely that enough context switches are
- going to occur between the UnlockIBase() and the ScreenToFoo() call
- which allow the ScreenToFoo()'d screen to close. ...but it is _possible_.
-
- I could Forbid()/Permit() the whole thing, but that seems generally
- unfriendly. It also tends to impact on system performance, especially
- when rapid-firing the ScreenSwitch hotkey.
-
- I've done some unscientific, niaeve, and generally inconclusive tests
- to determine reliability; ie, rapid-fire my hotkey du jour while
- applications open and close screens. This of course proves nothing,
- and doesn't help me sleep any better at night.
-
- So, is there a more air-tight method for this sort of thing without
- resorting to an evil Forbid()/Permit() pair?
-
- ----------------------------------------------------------------------
- "Stimpy, sometimes your wealth of ignorance astounds me." -ren hoek
- Bill Squier (groo@chsdip.wisdom.bubble.org) MetaMail capable
-