Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 William Stallings Computer Organization and Architecture Chapter 7 Operating System Support.

Similar presentations


Presentation on theme: "1 William Stallings Computer Organization and Architecture Chapter 7 Operating System Support."— Presentation transcript:

1 1 William Stallings Computer Organization and Architecture Chapter 7 Operating System Support

2 2 Objectives and Functions zConvenience yMaking the computer easier to use zEfficiency yAllowing better use of computer resources

3 3 Layers and Views of a Computer System

4 4 Operating System Services zProgram creation zProgram execution zAccess to I/O devices zControlled access to files zSystem access zError detection and response zAccounting

5 5 O/S as a Resource Manager

6 6 Types of Operating System zInteractive zBatch zSingle program (Uni-programming) zMulti-programming (Multi-tasking)

7 7 Early Systems zLate 1940s to mid 1950s zNo Operating System zPrograms interact directly with hardware zTwo main problems: yScheduling ySetup time

8 8 Simple Batch Systems zResident Monitor program zUsers submit jobs to operator zOperator batches jobs zMonitor controls sequence of events to process batch zWhen one job is finished, control returns to Monitor which reads next job zMonitor handles scheduling

9 9 Job Control Language zInstructions to Monitor zUsually denoted by $ ze.g. y$JOB y$FTN y...Some Fortran instructions y$LOAD y$RUN y...Some data y$END

10 10 Desirable Hardware Features zMemory protection yTo protect the Monitor zTimer yTo prevent a job monopolizing the system zPrivileged instructions yOnly executed by Monitor ye.g. I/O zInterrupts yAllows for relinquishing and regaining control

11 11 Multi-programmed Batch Systems zI/O devices very slow zWhen one program is waiting for I/O, another can use the CPU

12 12 Single Program

13 13 Multi-Programming with Two Programs

14 14 Multi-Programming with Three Programs

15 15 Time Sharing Systems zAllow users to interact directly with the computer yi.e. Interactive zMulti-programming allows a number of users to interact with the computer

16 16 Scheduling zKey to multi-programming zLong term zMedium term zShort term zI/O

17 17 Long Term Scheduling zDetermines which programs are submitted for processing zi.e. controls the degree of multi-programming zOnce submitted, a job becomes a process for the short term scheduler z(or it becomes a swapped out job for the medium term scheduler)

18 18 Medium Term Scheduling zPart of the swapping function (later…) zUsually based on the need to manage multi- programming zIf no virtual memory, memory management is also an issue

19 19 Short Term Scheduler zDispatcher zFine grained decisions of which job to execute next zi.e. which job actually gets to use the processor in the next time slot

20 20 Process States

21 21 Process Control Block zIdentifier zState zPriority zProgram counter zMemory pointers zContext data zI/O status zAccounting information

22 22 Key Elements of O/S

23 23 Process Scheduling Process Request End Long-Term Queue Short-Term Queue CPU I/O Queue I/O I/O Queue I/O I/O Queue I/O

24 24 Memory Management zUni-program yMemory split into two yOne for Operating System (monitor) yOne for currently executing program zMulti-program y“User” part is sub-divided and shared among active processes

25 25 Swapping zProblem: I/O is so slow compared with CPU that even in multi-programming system, CPU can be idle most of the time zSolutions: yIncrease main memory xExpensive xLeads to larger programs ySwapping

26 26 What is Swapping? zLong term queue of processes stored on disk zProcesses “swapped” in as space becomes available zAs a process completes it is moved out of main memory zIf none of the processes in memory are ready (i.e. all I/O blocked) ySwap out a blocked process to intermediate queue ySwap in a ready process or a new process yBut swapping is an I/O process...

27 27 Partitioning zSplitting memory into sections to allocate to processes (including Operating System) zFixed-sized partitions yMay not be equal size yProcess is fitted into smallest hole that will take it (best fit) ySome wasted memory yLeads to variable sized partitions

28 28 Fixed Partitioning

29 29 Variable Sized Partitions (1) zAllocate exactly the required memory to a process zThis leads to a hole at the end of memory, too small to use yOnly one small hole - less waste zWhen all processes are blocked, swap out a process and bring in another zNew process may be smaller than swapped out process zAnother hole

30 30 Variable Sized Partitions (2) zEventually have lots of holes (fragmentation) zSolutions: yCoalesce - Join adjacent holes into one large hole yCompaction - From time to time go through memory and move all hole into one free block (c.f. disk de- fragmentation)

31 31 Effect of Dynamic Partitioning

32 32 Relocation zNo guarantee that process will load into the same place in memory zInstructions contain addresses yLocations of data yAddresses for instructions (branching) zLogical address - relative to beginning of program zPhysical address - actual location in memory (this time) zAutomatic conversion using base address

33 33 Paging zSplit memory into equal sized, small chunks - page frames zSplit programs (processes) into equal sized small chunks - pages zAllocate the required number page frames to a process zOperating System maintains list of free frames zA process does not require contiguous page frames zUse page table to keep track

34 34 Logical and Physical Addresses - Paging

35 35 Virtual Memory zDemand paging yDo not require all pages of a process in memory yBring in pages as required zPage fault yRequired page is not in memory yOperating System must swap in required page yMay need to swap out a page to make space ySelect page to throw out based on recent history

36 36 Thrashing zToo many processes in too little memory zOperating System spends all its time swapping zLittle or no real work is done zDisk light is on all the time zSolutions yGood page replacement algorithms yReduce number of processes running yFit more memory

37 37 Bonus zWe do not need all of a process in memory for it to run zWe can swap in pages as required zSo - we can now run processes that are bigger than total memory available! zMain memory is called real memory zUser/programmer sees much bigger memory - virtual memory

38 38 Page Table Structure

39 39 Segmentation zPaging is not (usually) visible to the programmer zSegmentation is visible to the programmer zUsually different segments allocated to program and data zMay be a number of program and data segments

40 40 Advantages of Segmentation zSimplifies handling of growing data structures zAllows programs to be altered and recompiled independently, without re-linking and re-loading zLends itself to sharing among processes zLends itself to protection zSome systems combine segmentation with paging

41 41 Required Reading zStallings chapter 7 zStallings, W. Operating Systems, Internals and Design Principles, Prentice Hall 1998 zLoads of Web sites on Operating Systems


Download ppt "1 William Stallings Computer Organization and Architecture Chapter 7 Operating System Support."

Similar presentations


Ads by Google