Scheduling
Scheduling
Process Scheduling
• Maximize CPU use
• Quickly switch processes onto CPU for time
sharing
• Process “gives” up then CPU under two
conditions:
• I/O request
• After N units of time have elapsed (need a timer)
• Once a process gives up the CPU it is added
to the “ready queue”
• Process scheduler selects among available
processes in the ready queue for next
execution on CPU
Scheduling Queues
• OS Maintains scheduling queues of
processes
• Job queue – set of all processes in the
system
• Ready queue – set of all processes residing
in main memory, ready and waiting to
execute
• Device queues – set of processes waiting for
an I/O device
• Processes migrate among the various
queues
Ready Queue And Various I/O Device Queues
Representation of Process Scheduling
P2 P3 P1
0 3 6 30
P4 P1 P3 P2
0 3 9 16 24
P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30
System executes the highest priority process; processes with the same
priority will be run using round-robin.
• Example is Solaris
Multithreading
• The ability of an OS to
support multiple,
concurrent paths of
execution within a
single process.
Single Thread
Approaches
• MS-DOS supports a single
user process and a single
thread.
• Some UNIX, support
multiple user processes but
only support one thread
per process
Multithreading
• Java run-time environment
is a single process with
multiple threads
• Multiple processes and
threads are found in
Windows, Solaris, and many
modern versions of UNIX
One or More Threads in Process
• Each thread has
• An execution state (running, ready, etc.)
• Saved thread context when not running
• An execution stack
• Some per-thread static storage for local variables
• Access to the memory and resources of its process (all threads of a process
share this)
One view…