🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Steve D. Majewski Thu, 21 Jun 1990 21:39
Re: VMS(4.5)-CRTL sleep() sometimes doesn't sleep
#1
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads