Sleep

From COMP15212 Wiki
Revision as of 13:30, 4 August 2019 by pc>Yuron
Depends on SchedulerProcess 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.

Timer queue

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’ in file_input.c, but try and do without.)



Articles on Processes
About this resource • Atomicity • Containers • Context • Context Switching • Daemons • Fork Unix • Hypervisor • Idle • Interprocess Communication • Multi Threading • Mutual exclusion • Pipes • Pointer Arithmetic • Process Control Block (PCB) • Process Priority • Process Scheduling • Process States • Processes • Queues • Queues Extra • Race Conditions • Real Time • Resources • Scheduler • Signal and Wait • Sleep • Starvation • Synchronisation • Thrashing • Threads • Unix Signals