home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!news.tek.com!ogicse!decwrl!pa.dec.com!engage.pko.dec.com!ramblr.enet.dec.com!moroney
- From: moroney@ramblr.enet.dec.com
- Newsgroups: comp.os.vms
- Subject: Re: sys$hiber/sys$wake problems?
- Message-ID: <1992Nov11.004917.10003@engage.pko.dec.com>
- Date: 11 Nov 92 00:28:22 GMT
- Article-I.D.: engage.1992Nov11.004917.10003
- Sender: newsdaemon@engage.pko.dec.com (USENET News Daemon)
- Organization: Digital Equipment Corporation
- Lines: 56
-
- In article <BxIrqM.2pF@unx.sas.com>, sasjzs@falcon.unx.sas.com (Joseph Slater) writes...
- > And all others that responded via e-mail. You are correct,
- >however we aren't the ones calling sys$wake. After leaving
- >sys$hiber the next-to-last time, the bit pcb$v_wakepen bit is
- >clear. The next time we start to enter sys$hiber it is set and
- >we don't call sys$wake anywhere in between. (This is what
- >upsets us as we hope to set up things before calling sys$wake,
- >and when we don't we exit from hiber in an unknown state).
-
- Your code should be robust enough to deal with random wakes, as there
- may or may not be system code or other ASTs or timers that do $WAKES.
- Unlike event flags, there is only one "thing" so everyone must share.
-
- > I
- >suspect (thanks Matt) the PPL$ runtime library as this scheme
- >has worked successfully for many years and PPL is the only new
- >variable in the scheme.
-
- Probably right.
-
- > My next task is to try to trap calls
- >to sys$wake from the main and sharable images.
-
- You should recode your WAKE code as follows:
-
- AST routine:
-
- insert request in a queue
- SYS$WAKE(0,0)
-
-
- mainline code:
-
- initialize request queue (empty)
- exit_loop = false;
- do {
- try to remove request from request queue;
- if queue was empty {
- SYS$HIBER();
- } else {
- process work item;
- }
- } while not(exit_loop);
-
- If you follow this logic, first random wakes for no reason don't bother the
- process, it just checks and sees there's no work to do and goes back to sleep.
- It also handles the case of the AST firing like a machine gun, there can be
- many items at once, without an extra HIBER that can cause things to get out
- of sync.
-
- With this type of code, the PPL$ routines (or whoever) can $WAKE all it
- wants, all that happens is an extra trip through the loop.
- I even wrote code to throw random $WAKEs at processes using this type of
- code, just to be sure it was robust.
-
- -Mike
-