Docsity

Lecture Slides for Multiprogramming - Operating Systems | CS 1550, Study notes of Computer Science

Toggle sidebar
bg1
5/10/2009
1
CS 1550: Chapter 2
JonathanMisurda
http://www.cs.pitt.edu/~jmisurda/
Multiprogramming
ABCD
Multiple$PCs
(processpointofview)
A
C
Single$PC
(CPU’spointofview)
B
C
D
B
A
B
C
D
Time
Process
A
runningprogramanditsassociateddata
Life Cycle of a Process
Created
Ready
Blocked
(waiting)
Exit
Running
Process Table
Processes
Scheduler
0 1 N‐2N‐1
…
Process Table Entry
Filemanagement
Rootdirectory
Workin g(current)directory
Filedescriptors
User ID
Processmanagement
Registers
Programcounter
CPUstatusword
Stack pointer
Maybe
stored
onstack
User
ID
GroupID
Memorymanagement
Pointerstotext,data,stack
or
Pointertopagetable
Stack
pointer
Processstate
Priority/schedulingparameters
ProcessID
ParentprocessID
Signals
Processstarttime
Tota lCPUusage
pf3
pf4
pf5

Partial preview of the text

Download Lecture Slides for Multiprogramming - Operating Systems | CS 1550 and more Study notes Computer Science in PDF only on Docsity!

CS 1550: Chapter 2

Jonathan Misurda

[email protected]

http://www.cs.pitt.edu/~jmisurda/

Multiprogramming

A

B

C D

Multiple $PCs (process point of view)

A

C

Single $PC (CPU’s point of view)

B

C

D

B

A

B

C

D

Time

Process

A running program and its associated data

Life Cycle of a Process

Created

Ready

Blocked (waiting)

Exit

Running

Process Table

Processes

Scheduler

0 1 … N ‐ 2 N ‐ 1

Process Table Entry

File management

Root directory Working (current) directory File descriptors User ID

Process management

Registers Program counter CPU status word Stack pointer

May be stored on stack User ID Group ID

Memory management

Pointers to text, data, stack or Pointer to page table

Stack pointer Process state Priority / scheduling parameters Process ID Parent process ID Signals Process start time Total CPU usage

Thread

A stream of instructions and their associated

state

Processes and Threads

U

Process 1 Process 2 Process 3 Process 1

Kernel Kernel

Threads Threads System space

User space

Thread State

Per process items

Address space Open files Child processes Signals & handlers Accounting info Global variables

Per thread items

Program counter Registers Stack & stack pointer State

Per thread items

Program counter Registers Stack & stack pointer State

Per thread items

Program counter Registers Stack & stack pointer State

Threading

Process

Thread 1 Thread 2 Thread 3

Thread 1’s stack

User space

Kernel

Thread 3’s stack

Thread 2’s stack

Multithreading in Action

When becomes in the necessary Course of for human one people events, to it dissolve connected the them political with bands another, which and have to assume the separate among and the equal powers station of the to (^) whichearth, the entitle opinions Laws them, of of Naturemankind a decent and requires ofrespect Nature's (^) thatto the (^) theyGod should them to declare the separation. the causes which impel

We that hold all men these are truths created to be equal, self‐ thatevident, they certain are endowedunalienable by Rights, their Creator that among with these Happiness. are Life,‐‐That Liberty to secure and the these pursuit rights, of Governments Men, the consent deriving of are their the instituted justgoverned, powers among ‐‐That from whenever becomes any Form of Government

destructive of the People of these to alter ends, or to it abolish is the Right it, and laying to (^) itsinstitute foundation new Government, on such principles and as to organizing them shall its seem powers most in suchlikely form, to effect Prudence, Governments their Safety indeed, long and will established Happiness. dictate that should not causes; be changed and accordingly for light and all transient

Kernel

Multithreaded Webserver

Worker thread

while(TRUE) { getNextRequest(&buf); handoffWork(&buf); }

Webserver process

Kernel

Network connection

Web page cache

while(TRUE) { waitForWork(&buf); lookForPageInCache(&buf,&page); if(pageNotInCache(&page)) { readPageFromDisk(&buf,&page); } returnPage(&page); }

Throughput

Number of jobs completed per unit time

Turnaround Time

Time from job submission to job completion

Average Turnaround Time

Average of all turnaround times for a set of

jobs

Batch Scheduling

Non‐interactive jobs that can be run

“overnight”

First Come, First Served

A B C D

Current job queue

Execution order

FCFS scheduler

A B C D

Shortest Job First (SJF)

A B C D

Current job queue

B D A C

Execution order

SJF scheduler

Interactive scheduling

Impatient users waiting

Round Robin Scheduling

A B C D E

E

Quantum

Time

A

B

C

D

E

Priority Scheduling

Priority 4

Priority 3

P i it 2

High

Priority 2

Priority 1

Low Ready processes

Other Scheduling Algorithms

• Shortest Process Next

– SJF applied to Interactive Systems

• Guaranteed Scheduling

– N processes get 1/N of the CPU Time

• Lottery Scheduling

– Give out tickets, pull one at random, winner runs

• Fair Share

– N users get 1/N CPU time

Earliest Deadline First (EDF)

Real‐time: How you do homework

Mechanism

The way something is done (e.g., an algorithm)

Policy

The rules a particular mechanism should

follow (i.e., the parameters of an algorithm)