home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / amiga / programm / 11425 < prev    next >
Encoding:
Internet Message Format  |  1992-07-21  |  1.9 KB

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