DOC PREVIEW
UCSD CSE 120 - Scheduling and Deadlock

This preview shows page 1-2-3-4-5 out of 15 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 15 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 15 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 15 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 15 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 15 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 15 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1&6(3ULQFLSOHVRI2SHUDWLQJ6\VWHPV)DOOLecture 8: Scheduling and DeadlockGeoffrey M. VoelkerOctober 19, 2000 CSE 120 -- Lecture 8 – Scheduling and Deadlock 26FKHGXOLQJ2YHUYLHZ● In discussing process management and synchronization, we talked about context switching among processes/threads on the ready queue● But we have glossed over the details of exactly which thread is chosen from the ready queue● Making this decision is called scheduling● We’ll look at:◆ The goals of scheduling◆ Starvation◆ Various well-known scheduling algorithms◆ Standard Unix scheduling algorithm2October 19, 2000 CSE 120 -- Lecture 8 – Scheduling and Deadlock 30XOWLSURJUDPPLQJ● In a multiprogramming system, we try to increase CPU utilization and job throughput by overlapping I/O and CPU activities◆ Doing this requires a combination of mechanisms and policy● We have covered the mechanisms◆ Context switching, how and when it happens◆ Process queues and process states● Now we’ll look at the policies◆ Which process (thread) to run, for how long, etc.● We’ll refer to schedulable entities as jobs (standard usage) – could be processes, threads, people, etc.October 19, 2000 CSE 120 -- Lecture 8 – Scheduling and Deadlock 46FKHGXOLQJ*RDOV● Scheduling works at two levels in an operating system◆ To determine the multiprogramming level – the number of jobs loaded into primary memory» Moving jobs to/from memory is often called swapping◆ To decide what job to run next to guarantee “good service”» Good service could be one of many different criteria● These decisions are known as long-term and short-term scheduling decisions, respectively◆ Long-term scheduling happens relatively infrequently» Significant overhead in swapping a process out to disk◆ Short-term scheduling happens relatively frequently» Want to minimize the overhead of scheduling■ Fast context switches, fast queue manipulation3October 19, 2000 CSE 120 -- Lecture 8 – Scheduling and Deadlock 56FKHGXOLQJ● The scheduler (dispatcher) is the module that manipulates the queues, moving jobs to and fro● The scheduling algorithm determines which jobs are chosen to run next and what queues they wait on● In general, the scheduler runs:◆ When a job switches from running to waiting◆ When an interrupt occurs◆ When a job is created or terminated● We’ll discuss scheduling algorithms in two contexts◆ In preemptive systems the scheduler can interrupt a running job (involuntary context switch)◆ In non-preemptive systems, the scheduler waits for a running job to explicitly block (voluntary context switch)October 19, 2000 CSE 120 -- Lecture 8 – Scheduling and Deadlock 66FKHGXOLQJ*RDOV● Scheduling algorithms can have many different goals:◆ CPU utilization◆ Job throughput (# jobs/unit time)◆ Turnaround time (Tfinish– Tstart)◆ Waiting time (Avg(Twait): avg time spent on wait queues)◆ Response time (Avg(Tready): avg time spent on ready queue)● Batch systems◆ Strive for job throughput, turnaround time (supercomputers)● Interactive systems◆ Strive to minimize response time for interactive jobs (PC)4October 19, 2000 CSE 120 -- Lecture 8 – Scheduling and Deadlock 76WDUYDWLRQStarvation is a scheduling “non-goal”:● Starvation is a situation where a process is prevented from making progress because some other process has the resource it requires◆ Resource could be the CPU, or a lock (recall readers/writers)● Starvation usually a side effect of the sched. algorithm◆ A high priority process always prevents a low priority process from running on the CPU◆ One thread always beats another when acquiring a lock● Starvation can be a side effect of synchronization◆ Constant supply of readers always blocks out writersOctober 19, 2000 CSE 120 -- Lecture 8 – Scheduling and Deadlock 8)&)6),)2● First-come first-served (FCFS), first-in first-out (FIFO)◆ Jobs are scheduled in order of arrival to ready Q◆ “Real-world” scheduling of people in lines (e.g., supermarket)◆ Typically non-preemptive (no context switching at market)◆ Jobs treated equally, no starvation● Problem◆ Average waiting time can be large if small jobs wait behind long ones (high turnaround time)» You have a basket, but you’re stuck behind someone with a cart5October 19, 2000 CSE 120 -- Lecture 8 – Scheduling and Deadlock 96KRUWHVW-RE)LUVW6-)● Shortest Job First (SJF)◆ Choose the job with the smallest expected CPU burst» Person with smallest number of items to buy◆ Provably optimal minimum average waiting time● Problem◆ Impossible to know size of CPU burst» Like choosing person in line without looking at number of items ◆ How can you make a reasonable guess?◆ Can potentially starve● Flavors◆ Can be either preemptive or non-preemptive◆ Preemptive SJF is called shortest remaining time first (SRTF)October 19, 2000 CSE 120 -- Lecture 8 – Scheduling and Deadlock 103ULRULW\6FKHGXOLQJ● Priority Scheduling◆ Choose next job based on priority» Airline checkin for first class passengers◆ Can implement SJF, priority = expected CPU burst◆ Also can be either preemptive or non-preemptive◆ This is what you’re implementing in Nachos in Project 1● Problem◆ Starvation – low priority jobs can wait indefinitely● Solution ◆ “Age” processes» Increase priority as a function of waiting time» Decrease priority as a function of CPU consumption6October 19, 2000 CSE 120 -- Lecture 8 – Scheduling and Deadlock 115RXQG5RELQ55● Round Robin◆ Excellent for timesharing◆ Ready queue is treated as a circular queue (FIFO)◆ Each job is given a time slice called a quantum◆ A job executes for the duration of the quantum, or until it blocks or is interrupted◆ No starvation◆ Can be preemptive or non-preemptive● Problem◆ Context switches are frequent and need to be very fastOctober 19, 2000 CSE 120 -- Lecture 8 – Scheduling and Deadlock 12&RPELQLQJ$OJRULWKPV● Scheduling algorithms can be combined◆ Have multiple queues◆ Use a different algorithm for each queue◆ Move processes among queues● Example: Multiple-level feedback queues (MLFQ)◆ Multiple queues representing different job types» Interactive, CPU-bound, batch, system, etc.◆ Queues have priorities, jobs on same queue scheduled RR◆ Jobs can move among queues based upon execution history» Feedback: Switch from


View Full Document

UCSD CSE 120 - Scheduling and Deadlock

Documents in this Course
Threads

Threads

14 pages

Deadlocks

Deadlocks

19 pages

Processes

Processes

14 pages

Paging

Paging

13 pages

Processes

Processes

18 pages

Threads

Threads

29 pages

Security

Security

16 pages

Paging

Paging

13 pages

Processes

Processes

32 pages

Lecture 2

Lecture 2

13 pages

Paging

Paging

8 pages

Threads

Threads

14 pages

Paging

Paging

13 pages

Paging

Paging

26 pages

Paging

Paging

13 pages

Lecture

Lecture

13 pages

Processes

Processes

14 pages

Paging

Paging

13 pages

Security

Security

17 pages

Threads

Threads

15 pages

Processes

Processes

34 pages

Structure

Structure

10 pages

Lecture 3

Lecture 3

13 pages

Lecture 1

Lecture 1

28 pages

Threads

Threads

15 pages

Paging

Paging

30 pages

Load more
Download Scheduling and Deadlock
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Scheduling and Deadlock and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Scheduling and Deadlock 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?