) – selects which process (only
one) should be executed next and allocates CPU
●
Sometimes the only scheduler in a system
●
Short-term scheduler is invoked frequently (milliseconds)
Þ
(must be
fast)
■
Long-term scheduler
(or
job scheduler
) – selects which processes should
be brought into the ready queue (into the memory)
●
Long-term scheduler is invoked
infrequently (seconds, minutes)
Þ
(may be slow)
●
The long-term scheduler controls the
degree of multiprogramming
(the number of processes in memory)
■
Processes can be described as either:
●
I/O-bound process
– spends more time doing I/O than computations,
many short CPU bursts
●
CPU-bound process
– spends more time doing computations; few very
long CPU bursts
What if all processes are I/O-
bound or CPU-bound?

3.17
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9
th
Edition
Schedulers
■
Long-term scheduler strives for good
process mix
●
Balancing I/O-bound and CPU-bound processes
■
Long-term scheduler
may be absent
●
Time-sharing systems such as Unix and Windows have no long-
term scheduler but simply put every new process in memory for
the short-term scheduler

3.18
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9
th
Edition
Addition of Medium Term Scheduling
■
Medium-term scheduler
can be added if degree of multiple
programming needs to decrease
●
Remove process from memory, store on disk, bring back in from
disk to continue execution:
swapping
●
Why medium-term scheduler?
●
To improve process mix or to free up memory for overflow

3.19
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9
th
Edition
Context Switch
■
When CPU switches to another process, the system must
save
the state
of the old process and load the
saved state
for the
new process via a
context switch
■
Context
of a process represented in the PCB
■
Context-switch time is overhead; the system does no useful
work while switching
●
The more complex the OS and the PCB
è
the longer the
context switch
■
Time dependent on hardware support
●
Some hardware provides multiple sets of registers per CPU
è
multiple contexts loaded at once
Multiprogramming is different from
swapping, why?

3.20
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9
th
Edition
Multitasking in Mobile Systems
■
Some mobile systems (e.g., early version of iOS)
allow only one
application process to run, others suspended (system processes
not impacted)
■
Due to screen constraint, user interface limits iOS provides
●
Single
foreground
process- controlled via user interface
●
Multiple
background
processes– in memory, running, but not
on the display, and with limits
●
Limits include single, short task, receiving notification of events,
specific long-running tasks like audio playback
■
Android runs foreground and background, with fewer limits
●
Background process uses a
service
to perform tasks
●
Service can keep running even if background process is
suspended
●
Service has no user interface, small memory use
●
Now supports multiple foreground apps

3.21

