sleep_h(PCI) 6 January 1993 sleep_h(PCI) Name sleep_h - suspend DOS execution Syntax void sleep_h(h) unsigned short h; Description sleeph() suspends the calling process for approximately h hundredths of a second. Interrupt routines continue to execute as interrupts occur during the sleep. In a DOS Merge environment, sleeph() actually relinquishes the processor to other UNIX operating system processes, waking up and checking on each virtual interrupt to see whether the requested amount of time has elapsed. When the requested time has elapsed, sleeph() returns to the caller. The use of sleeph() is recommended in preference to busy-wait loops, which degrade overall system performance when run in a virtual DOS environment on a timeshare system. Implementation notes The requested duration of sleep time is rounded to the nearest DOS vir- tual tick, where one DOS virtual tick interval is approximately 5.5 hun- dredths of a second. (More precisely, DOS virtual ticks occur at the rate of (1193180/65536) per second; sleeph() assumes a conversion to the rate of (1193200/65536) DOS virtual ticks per second.) sleeph() waits for the appropriate number of DOS virtual ticks to occur, and then returns to the caller. Note that the amount of time that actu- ally passes before the first tick occurs depends on how much time has already passed in the current tick interval when sleeph() is called. If the requested duration of sleep time rounds to zero DOS virtual ticks, the calling process is suspended until the next interrupt. (This will not necessarily be a clock interrupt.) If the calling process is running in a virtual DOS environment under DOS Merge and fastclk is not set, DOS virtual time is only updated approxi- mately once every second, or once every 18 DOS virtual ticks. Thus, for delays on the order of several seconds or more, the time slept will be reasonably accurate, but for smaller delays the granularity may be unac- ceptable. If the fastclk option is enabled under DOS Merge, then DOS virtual time is updated at every DOS virtual tick interval, just as it is in a stan- dard DOS environment. Even if fastclk is set, UNIX operating system process scheduling will affect the actual time slept in a virtual DOS environment. If the DOS clock has been reprogrammed, then sleeph() should not be used since it assumes the default clock rate. Example : : int driveNum; int status; int blockFlag; pid_t retVal; : : /* ** Use sleep_h() with all nonblocking functions. ** In this example we use the sleep_h() with the ** uwait() function. (see MAN page for uwait()). ** ** Use UWAIT to wait for a child process ** on virtual drive D: (4) to exit. */ driveNum = 4; blockFlag = 0; /* nonblocking */ /* loop till a child exits */ while ( (retVal = uwait(driveNum, &status, blockFlag)) == 0L ) sleep_h(25); /* sleep for a quarter of a second */ if (retVal == -1L) errorHandler(); else checkStatus(); : : See also The command merge set fastclk [on|off] in the DOS Merge documentation.