Information Technology Reference
In-Depth Information
Separating mechanism from policy
Separating mechanism from policy is a useful and widely-applied principle in operat-
ing system design. When mechanism and policy are cleanly separated, it is easier to
introduce new policies to optimize a system for a new workload or new technology.
For example, the thread context switch abstraction cleanly separates mechanism
(how to switch between threads) from policy (which thread to run) so that the mechanism
works no matter what policy is used. Then, some systems can elect to do something
simple (e.g., FIFO scheduling), while other systems can optimize scheduling to meet
their goals (e.g., a periodic scheduler to smoothly run real-time multimedia streams for
a media device, a round-robin scheduler to balance responsiveness and throughput for
a server, or a priority scheduler that devotes most resources to the visible application
on a smartphone.)
We will see this principle many times in this topic. For example, thread synchro-
nization mechanism are also designed to work regardless of the scheduling policy, file
metadata mechanisms for locating a file's blocks are designed to work regardless of
the policy for choosing where to place the file's blocks on disk, and page translation
mechanisms for mapping virtual page addresses to physical page addresses work re-
gardless of which ranges of virtual addresses a process uses and which physical pages
the operating system assigns to it.
WhichReadythread should the scheduler choose to run next?
The mechanisms we discuss work regardless of what policy the scheduler uses
when choosing threads.
As for the policy for choosing whichReadyto run next, there are trade-offs
among different scheduling policies, and different operating systems use different
approaches. We therefore defer discussing scheduling policy to Chapter 7 where
we can discuss these policy trade-offs in depth.
For now, you can assume that the scheduler's ready list is a simple FIFO
list; most schedulers do something more sophisticated|they may prioritize some
threads over others, optimize for throughput or responsiveness, or run ensure
that multimedia threads run at a regular interval|but nothing we talk about
here depends on these details.
What triggers a kernel thread context switch?
When a thread in the kernel is running, two things can cause a thread context
switch.
First, the thread may call a thread library function that triggers a context
switch.
For example, many thread libraries provide a threadyield() call
Search WWH ::




Custom Search