Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: tp@mccall.com
Subject: Re: VMS(4.5)-CRTL sleep() sometimes doesn't sleep
Date: 22 Jun 90 09:36:58 GMT	[thread overview]
Message-ID: <2932.2681e6bc@mccall.com> (raw)
In-Reply-To: 1990Jun21.213912.28758@murdoch.acc.Virginia.EDU

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 <tp@mccall.com>                The McCall Pattern Company
(uucp: ...!rutgers!ksuvax1!mccall!tp)     615 McCall Road
(800)255-2762, in KS (913)776-4041        Manhattan, KS 66502, USA


      reply	other threads:[~1990-06-22  9:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1990-06-20 18:56 VMS(4.5)-CRTL sleep() sometimes doesn't sleep Steve D. Majewski
1990-06-21 21:39 ` Steve D. Majewski
1990-06-22  9:36   ` tp [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox