🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: uva.vms
Article #1

Re: VMS(4.5)-CRTL sleep() sometimes doesn't sleep

#1
From: Steve D. Majewski
Date: Thu, 21 Jun 1990 21:39
56 lines
3389 bytes
  Thanks to all those who responded to my problems.
  To summarize what I have learned, both from my respondants and
  from a little experimenting & debugging:

 IN GENERAL: 
   Sleep( n ) CAN'T be relied upon to sleep n seconds.
   It calls $SCHDWK & $HIBER. There are several events that cause a
   state change from HIB and sleep does not check that the time has
   actually expired, before returning "n" , making it appear to has
   been successful. ( Actually, you should think of sleep() as pause()
   with a timeout value ! - Is this implementation meant to capture
   the bugs/features/behavior of the Unix vesion ? )  
   If you really want to "sleep" n seconds, use $SETIMR & $WAITFR.

  SPECIFICALLY, 
  in my program, the other event that was waking sleep early was: 

		SYS$WAKE( &correlate_pid, 0 );
			.
			.
			.
		sleep( collect_time );
			.
			.
			.

  While debugging, the vfork()/execle() to create the correlation process
  was not done, so that I could use the debugger. ( spawning a sub-process
  with vfork()/execle() seems to work quit differently than LIB$SPAWN: 
  among other things, it seems to be fatal to the debugger. ) 
  Thus, correlate_pid == 0, and as we all know, almost all of the system
  services that use a PID, interpret PID=0 to mean "ME" , the calling
  process. 
  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.
  But a change to:

		if ( correlate_pid ) SYS$WAKE( &correlate_pid, 0 );

  seems to have fixed things.

  I may STILL have to change to a $SETIMR/$WAITFR method of sleeping, 
  since this is a data collection program that relies on "sleep( 10 )"
  actually getting 10 seconds of X-rays accumulated in a spectrometer!
  ( I don't need millisecond resolution guaranteed, it's not THAT 
  REALTIME, but I need to rely on it being better than a second, and
  now that I know a bit about the inner workings of "sleep", I don't
  trust it. - time to dig out the Big Black Book (VAX/VMS Internals &
  Data Structures) and see what these system services actually DO ! ) 
  
-------------------------------------------------------------------------
 Steven D. Majewski		University of Virginia Physiology Dept.
 sdm7g@virginia.edu		Box 449 Health Sciences Center
 (804) 982-0831			Charlottesville, VA 22908
Technical Details
Message-ID: <1990Jun21.213912.28758@murdoch.acc.Virginia.EDU>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-vmsnet.misc.mbox.zip!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!uvaarpa!murdoch!news
References: <1990Jun20.185657.27108@murdoch.acc.Virginia.EDU>

Show Full Headers
Complete Article Headers
Message-ID: <1990Jun21.213912.28758@murdoch.acc.Virginia.EDU>
Subject: Re: VMS(4.5)-CRTL sleep() sometimes doesn't sleep
Date: Thu, 21 Jun 1990 21:39:12 +0000
From: sdm7g@dale.acc.Virginia.EDU (Steve D. Majewski)
References: <1990Jun20.185657.27108@murdoch.acc.Virginia.EDU>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-vmsnet.misc.mbox.zip!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!uvaarpa!murdoch!news
Newsgroups: comp.os.vms,comp.sys.dec,vmsnet.misc,uva.vms
Keywords: sleep $HIBER $WAKE $SCHDWK CRTL
Sender: news@murdoch.acc.Virginia.EDU
Followup-To: comp.sys.dec
Organization: University of Virginia
Lines: 56
Posted: Thu Jun 21 22:39:12 1990