Chap 6 Flashcards
Scheduling
◼ The scheduler chooses one of the ready threads to allocate to the CPU when it is available.
◼ The scheduling policy determines when it is time
for a thread to be removed from the CPU and allocate it to another thread.
◼ The scheduling mechanism determines how the
process manager can determine it is time to interrupt the CPU, and how a thread can be
allocated to and removed from the CPU.
Scheduling Mechanisms
When a process/thread is changed into the ready
state, the enqueuer enqueues the corresponding
descriptor into a list of processes that are waiting for
the CPU (or the ready list). The enqueuer may place
the new process anywhere in the list, depending on
the scheduling policy.
When the scheduler switches the CPU from executing
one process to another, the context switcher saves
the contents of all CPU registers (PC, IR, condition
status, processor status, and ALU status) for the
thread being removed into its descriptor.
The dispatcher is invoked after the current process is
removed from the CPU. The dispatcher removes one
of the threads from the ready list and then allocates it
to the CPU by loading its CPU registers in the
thread’s descriptor into the CPU.
First-Come First-Served FCFS (advantage & disadvantage)
◼ Advantages:
Simplest CPU scheduling algorithm
◼ Disadvantage
Convoy effect: short process behind long process and waiting for the long process to finished. This results in lower CPU and
devices utilization.
Shortest-Job-First (SJF) Two methods
nonpreemptive - Once CPU is allocated to a process it cannot
be preempted until it completes its service time.
preemptive - A current process is preempted if a new process
arrives with service time length lesser than the current process’s
remaining service time.
Priority Scheduling (problem and solution)
◼ Problem: Starvation
Low priority processes may never be executed.
◼ Solution: Aging
Increase the priority of the process as time
progresses.
Round-Robin (RR) Performance
Performance. It depends on size of time quantum:
large quantum (q). This is equivalent to FIFO.
small quantum (q). It must be large with respect to the context
switch, otherwise overhead is too high.