Presentation is loading. Please wait.

Presentation is loading. Please wait.

Operating Systems: Introduction n 1. Historical Development n 2. The OS as a Resource Manager n 3. Definitions n 4. The Process.

Similar presentations

Presentation on theme: "Operating Systems: Introduction n 1. Historical Development n 2. The OS as a Resource Manager n 3. Definitions n 4. The Process."— Presentation transcript:

1 Operating Systems: Introduction n 1. Historical Development n 2. The OS as a Resource Manager n 3. Definitions n 4. The Process

2 The OS as a Resource Manager n Resources –4 functions n Keep track of resource n Enforce policy - n Allocate n Reclaim

3 The OS as a Resource Manager n Memory management –Keep track –If multiprogramming: –Allocate –Reclaim (p i relinquishes it or terminates)

4 The OS as a Resource Manager n Processor management –Keep track of –Scheduling: –Allocate : –Reclaim : p i relinquishes P, terminates, exceeds TS

5 n Device management –Keep track of devices, channels, control units –Efficient allocation policy –Allocate : –Reclaim : Normally automatic termination The OS as a Resource Manager

6 n Information management –Keep track : Location, use, status ( ) –Who gets use of resources, enforce protection, provide accessing routines –Allocate (“Open file”) –Deallocate (“Close file”) The OS as a Resource Manager

7 Bare machine Level 1 Processor management lower module (P,V), Process Scheduler Level 2 Memory management Level 3 Processor management upper module (messages, create- destroy process) Level 4 Device management (I/O traffic control) Info management (File system) Level 5 Kernel

8 I/O process User-created process I/O process working with User process 3 SPOOLing Process 1Process 2 Process 3 Supervisor process (Job scheduler) Jobs Hierarchical OS Structure Kernel (Layer 0) Layer 1 Layer 2

9 Definitions n Operating System (OS) : –Software governing control of resources –( ) –Interface n Processor : Hardware which interprets and executes instructions n Process (task) : n Job : Set of modules req’d to perform some task

10 Definitions n Multiprogramming : n Privileged instruction : –Instruction available only to –Executed in supervisor (executive) state as opposed to problem (user) state. n Interrupt : –Mechanism forcing processor to take notice of event

11 I.4 The Process n Process (p i ) : A program in a state of execution n Life : (Higher level view) –1. Run : p i <-P –2. Wait : For event –3. Ready : RUN READYWAIT p i P Wait for I/O completion I/O complete

12 Life of a Process n Lower level view : RUN WAITREADYHOLD SUBMIT COMPLETE

13 Processor Management and Scheduling Processor Management and Scheduling n 1. Introduction n 2. Basic Concepts n 3. Processor Scheduling Algorithms

14 Introduction Introduction n Given : 2 jobs, A and B. n Each executes for 1 sec, waits for 1 sec n Repeat this for 60 cycles [ 2 min ] –1. Let’s run A, then B A: B: 2 min Elapsed Time : 4 minCompute Time : 2 min CPU Utilization : 2/4 = 50%

15 –2. Now multi-program A and B A: B: Introduction Elapsed Time : 2+ min Compute Time : 2 min CPU Utilization : 2/2+ = ~100% –Compare to 1 : A finishes at same time, – Compare to 1 : A finishes at same time, B in half the time. B in half the time.

16 n So now we have multiprogramming: –N jobs in memory –Job i P –When i waits for I/O, j P n Overlap CPU and I/O to keep P busy –Benefits : Increased CPU utilization and higher throughput. n Throughput : Work done in given period. –E.g. 10 jobs per hour. Introduction

17 Basic Concepts Basic Concepts n Process : a program in a state of execution. –E.g. Batch job, transaction (in T-S system) –Also called : job, program, task, activity. n Process behavior : p i alternate between execution(CPU burst) & I/O(I/O burst). –Generally begins and ends with CPU bursts.

18 Basic Concepts n p i change state as they execute –READY, RUN, WAIT, HOLD. n Process Control Block (PCB) –Process is represented internally by its PCB –Active representation of passive entity, the PGM n “The only tangible part of a process”

19 –PCB n Process id n Current State n Priority n Other CPU Scheduling info n State info : PC (address of NI to be executed) register, cc contents n Memory management info : base-bounds registers, page tables n Accounting info : amount of CPU time, account # n I/O status info : I/O requests pending, I/O devices allocated, list of open files n Pointer to list of all p i in same state n etc.

20 Basic Concepts n Scheduling queues –Ready queue : List of processes (PCBs) in ready state (awaiting assignment of P) –Device queue : List of p i waiting on this device –I/O queue : p i waiting for I/O (once served, p i moves to Ready queue). Head Tail PCB i Registers...... PCB jPCB n Registers............ Queue header...

21 Basic Concepts n Schedulers : –Job (long-term) scheduler : n Selects job from spool queue to enter system, loads it into memory –Processor (CPU, short-term) scheduler : n Selects ready p i and dispatches (assigns P to) it

22 –Difference : How often they execute –Job scheduler n Infrequently once steady state is reached n Controls degree of multiprogramming (number of p i in memory) –Processor scheduler n Must select new p i very frequently (every 10 ms) n FAST or much of the processor time is spent in scheduling !

23 Basic Concepts n Dispatcher –Assigns P to p i selected by Processor scheduler –Loads p i ’s registers –Changes to user mode –Jumps to proper address [ to (re)start it ]

24 Processor Scheduling Algorithms Processor Scheduling Algorithms n Problem : Which p i in Ready queue gets P? n Performance Criteria (Comparing algorithms): –Throughput : Work done in given period. –CPU utilization : P busy time / Total elapsed time n Want it as busy as possible (40-90%). –Turnaround time : Interval between submission to completion of job (Batch OS). –Wait time : Time spent by p i in Ready queue. –Response time : Interval from submission until response produced (Interactive system).

25 Processor Scheduling Algorithms n Let’s optimize as follows : –Maximize CPU utilization, throughput –Minimize turnaround time (TT), wait, response time. –Operationally : n Optimize average or max or min n e.g. Minimize the max response time Minimize variance in response time.

26 Common Scheduling Algorithms n (a) First Come First Served (FCFS) n (b) Shortest Job First (SJF) n (c) Priority –Preemptive vs Non-preemptive n (d) Round Robin n (e) Multilevel Queues

27 Scheduling Algorithms n First Come First Served (FCFS) –Implementation : FIFO queue –p j enters ready q : –p i dispatched : –Consider :Job CPU burst A 24 B 3 C 3 pipi pkpk pjpj pkpk pjpj... RQ RQ

28 n FCFS –Suppose jobs arrive in order A, B, C and are served FCFS. n TT : For A = 24, For B = 27, For C = 30 n Avg TT : (24 + 27 + 30) / 3 = 27 –Now, suppose they arrive in order B, C, A n Avg TT : (3 + 6 + 30) / 3 = 13 ABC 242730 ABC 6 3 0 0

29 Scheduling Algorithms n Shortest Job First (SJF) –Associates with job the length of its next CPU burst –Example of priority scheduling (job with shortest next CPU burst gets highest priority) –Consider :Job CPU burst A 6 B 3 C 8 D 7

30 n SJF n Avg TT : (3 + 9 + 16 + 24) / 4 = 13 –This algorithm can be proved optimal n Gives min avg wait time for given set of jobs –Problem : Length of next CPU burst n Batch jobs : Time limit supplied by user n Processes : Can’t know [but can predict] B[3]D[7]C[8]A[6] 0 00 0 3 9 99 91624

31 Scheduling Algorithms n Priority Scheduling –Can be assigned : who is paying, type of work –Can be computed : n Time limits, memory req., ratio avg I/O burst to CPU burst, number of open files –Major problem : Starvation n Low priority Ready p i can wait indefinitely for CPU n Eventually, load lightens and job gets run, or system crashes and job is lost –Remedy n Aging : Increase priority of low priority job over time

32 Scheduling algorithms n Round Robin (RR) –Designed for TS systems n Given defined TS (10-100 ms). –CPU scheduler traverses Ready queue, selects p i to be dispatched for interval  TS –Implementation : n Ready queue = FIFO queue n CPU scheduler picks 1st job in Ready queue n Sets timer to interrupt after 1 TS n Dispatches process

33 n Multilevel Queue –Good when jobs easily classified into groups n e.g. foreground (FG - interactive) and background (BG - batch) –In a multilevel scheduling algorithm : n Ready queue partitioned into separate queues n Each p i assigned permanently to one queue –Due to memory size, job type, … n Each queue has its own scheduling algorithm –FG : RR, BG : FCFS n Must have scheduling between the queues –e.g. Fixed priority preemptive (such as FG > BG) Scheduling algorithms

Download ppt "Operating Systems: Introduction n 1. Historical Development n 2. The OS as a Resource Manager n 3. Definitions n 4. The Process."

Similar presentations

Ads by Google