Sleep: Difference between revisions
pc>Yuron No edit summary |
Yuron [PHRhYmxlIGNsYXNzPSJ0d3BvcHVwIj48dHI+PHRkIGNsYXNzPSJ0d3BvcHVwLWVudHJ5dGl0bGUiPkdyb3Vwczo8L3RkPjx0ZD51c2VyPGJyIC8+YnVyZWF1Y3JhdDxiciAvPmludGVyZmFjZS1hZG1pbjxiciAvPnN5c29wPGJyIC8+PC90ZD48L3RyPjwvdGFibGU+] (talk | contribs) m (1 revision imported) |
(No difference)
|
Revision as of 12:46, 26 July 2019
Depends on | Scheduler • Process States |
---|
Note: this article is about a process becoming blocked for a while on a timer. It is different from the process-synchronisation “sleep”.
“Sleep” is a Unix name for a process suspended (blocked) waiting for a time.
Experiment: try: “
sleep 5; echo Wake up.
” in a Unix shell.
Any number (within reason!) of processes may be sleeping at the same time. As there is not ‘any number’ of hardware clocks available, it is likely that all sleeping processes will be queued, sorted chronologically and rescheduled (unblocked) by a timer interrupt.
Inside a C program, the library call sleep(<seconds>)
will provide
the appropriate system call.
Exercise: write a little application which prints output at a human-readable rate using
sleep()
calls to regulate progress. (There are some ‘hints’ infile_input.c
, but try and do without.)