From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,6d50c88b54316cb9 X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1990-06-22 15:14:58 PST Path: gmdzi!unido!mcsun!uunet!maverick.ksu.ksu.edu!deimos.cis.ksu.edu!mccall!tp From: tp@mccall.com Newsgroups: comp.sys.dec Subject: Re: VMS(4.5)-CRTL sleep() sometimes doesn't sleep Message-ID: <2932.2681e6bc@mccall.com> Date: 22 Jun 90 09:36:58 GMT References: <1990Jun20.185657.27108@murdoch.acc.Virginia.EDU> <1990Jun21.213912.28758@murdoch.acc.Virginia.EDU> Followup-To: comp.sys.dec Organization: The McCall Pattern Co., Manhattan, KS, USA Posted: Fri Jun 22 10:36:58 1990 In article <1990Jun21.213912.28758@murdoch.acc.Virginia.EDU>, sdm7g@dale.acc.Virginia.EDU (Steve D. Majewski) writes: > WHY calling SYS$WAKE BEFORE calling sleep makes sleep wake early is > not obvious on the surface. I assume it has something to do with the > calls affecting the process scheduling rather than the process directly. Actually, this is the documented behavior of SYS$WAKE and SYS$HIBER. Look in the VMS system services manuals. Any code that hibernates for a reason (i.e. waiting for something to happen) MUST check that those conditions have been met when it wakes, or it will run in correctly, just as you report. If there is a pending wake when SYS$HIBER is called, it returns immediately, as you have seen. (It doesn't count them by the way, there is just a flag somewhere that says SYS$WAKE has been called.) These services are defined this way to prevent race conditions. The normal way to use them is to set AST's for the events you are interested in, and then hibernate. The AST routine calls SYS$WAKE. When the AST routine returns, the program falls out of SYS$HIBER. Now think about what would happen if you set up the AST, but the event happened BEFORE you actually got into SYS$HIBER. The way they currently work, it would fall out of SYS$HIBER immediately, which is exactly the right thing. If it didn't do this, it would process the AST and then hibernate, never to wake up (unless another event will happen later that does a SYS$WAKE). -- Terry Poot The McCall Pattern Company (uucp: ...!rutgers!ksuvax1!mccall!tp) 615 McCall Road (800)255-2762, in KS (913)776-4041 Manhattan, KS 66502, USA