1 / 48

William Stallings Computer Organization and Architecture

William Stallings Computer Organization and Architecture. Chapter 8 Operating System Support. Objectives and Functions. Convenience Making the computer easier to use Efficiency Allowing better use of computer resources. Layers and Views of a Computer System. Operating System Services.

uriel
Download Presentation

William Stallings Computer Organization and Architecture

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. William Stallings Computer Organization and Architecture Chapter 8 Operating System Support Rev. by Luciano Gualà (2008)

  2. Objectives and Functions • Convenience • Making the computer easier to use • Efficiency • Allowing better use of computer resources Rev. by Luciano Gualà (2008)

  3. Layers and Views of a Computer System Rev. by Luciano Gualà (2008)

  4. Operating System Services • Program creation • Program execution • Access to I/O devices • Controlled access to files • System access • Error detection and response • Accounting Rev. by Luciano Gualà (2008)

  5. OS as Resource Manager • OS is responsible for managing resources of the computer • OS is an unusual control mechanism in two respects: • it functions in the same way as a ordinary computer software • it frequently relinquishes control and must depend on the processor to allow it to regain control Rev. by Luciano Gualà (2008)

  6. O/S as a Resource Manager Rev. by Luciano Gualà (2008)

  7. Types of Operating System • Batch • Interactive • Single program (Uni-programming) • Multiple programs (Multi-tasking) Rev. by Luciano Gualà (2008)

  8. Early Systems • Late 1940s to mid 1950s • No Operating System • Programs interact directly with hardware • Two main problems: • Scheduling • Set-up time Rev. by Luciano Gualà (2008)

  9. Simple Batch Systems • Resident Monitor program • Users submit jobs to operator • Operator batches jobs • Monitor controls sequence of events to process batch • When one job is finished, control returns to Monitor which reads next job • Monitor handles scheduling Rev. by Luciano Gualà (2008)

  10. Job Control Language • Instructions to Monitor • Usually denoted by $ • e.g. • $JOB • $FTN • ... Some Fortran instructions • $LOAD • $RUN • ... Some data • $END Rev. by Luciano Gualà (2008)

  11. Desirable Hardware Features • Memory protection • To protect the Monitor • Timer • To prevent a job monopolizing the system • Privileged instructions • Only executed by Monitor • e.g. I/O • Interrupts • Allows for relinquishing and regaining control Rev. by Luciano Gualà (2008)

  12. Overhead • Two sacrifices: • some main memory is used by the monitor • some CPU time is consumed by the monitor Rev. by Luciano Gualà (2008)

  13. Multi-programmed Batch Systems • I/O devices very slow • When one program is waiting for I/O, another can use the CPU Rev. by Luciano Gualà (2008)

  14. Single Program Rev. by Luciano Gualà (2008)

  15. Multi-Programming with Two Programs Rev. by Luciano Gualà (2008)

  16. Multi-Programming with Three Programs Rev. by Luciano Gualà (2008)

  17. Time Sharing Systems • Allow users to interact directly with the computer • i.e. Interactive • Multi-programming allows a number of users to interact with the computer Rev. by Luciano Gualà (2008)

  18. concept of process • several definitions including: • a program in execution • the “animated spirit” of a program • the entity to which a processor is assigned Rev. by Luciano Gualà (2008)

  19. Scheduling • Key to multi-programming • Long term • Medium term • Short term • I/O Rev. by Luciano Gualà (2008)

  20. Long Term Scheduling • Determines which programs are accepted for processing • i.e. controls the degree of multi-programming • Once accepted, a job becomes a process for the short term scheduler • (or it becomes a swapped out job for the medium term scheduler) • two kinds of decisions: • can we accept a new job for processing? • which job do we select? • several criteria: priority, expected execution time, I/O requirement Rev. by Luciano Gualà (2008)

  21. Medium Term Scheduling • Determines which process can be entered in the central memory (i.e., swapped in) • Part of the swapping function (later…) Rev. by Luciano Gualà (2008)

  22. Short Term Scheduler • Dispatcher • Fine grained decisions of which job to execute next • i.e. which job actually gets to use the processor in the next time slot Rev. by Luciano Gualà (2008)

  23. Process States Long Term Sched. Medium Term Sched. Short Term Sched. Rev. by Luciano Gualà (2008)

  24. Process Control Block • Identifier • State • Priority • Program counter • Process Memory pointers • Context data • I/O status • Accounting information Rev. by Luciano Gualà (2008)

  25. CPU CPU CPU A simple example Operating System Operating System Operating System Service handler Service handler Service handler scheduler scheduler scheduler Interrupt handler Interrupt handler Interrupt handler A A A “running” “waiting” “waiting” B B B “ready” “ready” “running” Other partitions Other partitions Other partitions Rev. by Luciano Gualà (2008)

  26. Key Elements of O/S Rev. by Luciano Gualà (2008)

  27. Short-Term Queue Long-Term Queue CPU I/O I/O I/O I/O Queue I/O Queue I/O Queue Process Scheduling Process Request End usually a round-robin algorithm is used Rev. by Luciano Gualà (2008)

  28. Memory Management • Uni-program • Memory split into two • One for Operating System (monitor) • One for currently executing program • Multi-program • “User” part is sub-divided and shared among active processes • Requires memory management capabilities Rev. by Luciano Gualà (2008)

  29. Swapping • Problem: I/O is so slow compared with CPU that even in multi-programming system, CPU can be idle most of the time • Solutions: • Increase main memory • Expensive • Leads to larger programs • Swapping Rev. by Luciano Gualà (2008)

  30. What is Swapping? • Long term queue of processes stored on disk • As a process completes it is moved out of main memory • Processes “swapped” in as space becomes available • If none of the processes in memory are ready (i.e. all I/O blocked) • Swap out a blocked process to intermediate queue • Swap in a ready process or a new process • But swapping is an I/O process... Rev. by Luciano Gualà (2008)

  31. Swapping disk storage main memory Operating System intermediate queue completed jobs long-term queue Rev. by Luciano Gualà (2008)

  32. Partitioning • Splitting memory into sections to allocate to processes (including Operating System) • Fixed-sized partitions • May not be equal size • Process is fitted into smallest hole that will take it (best fit) • Some wasted memory • Leads to variable sized partitions Rev. by Luciano Gualà (2008)

  33. FixedPartitioning Rev. by Luciano Gualà (2008)

  34. Variable Sized Partitions (1) • Allocate exactly the required memory to a process • This leads to a hole at the end of memory, too small to use • Only one small hole - less waste • When all processes are blocked, swap out a process and bring in another • New process may be smaller than swapped out process • Another hole Rev. by Luciano Gualà (2008)

  35. Effect of Dynamic Partitioning Rev. by Luciano Gualà (2008)

  36. Variable Sized Partitions (2) • Eventually have lots of holes (fragmentation) • Solutions: • Compaction - From time to time go through memory and move all hole into one free block Rev. by Luciano Gualà (2008)

  37. Relocation • No guarantee that process will load into the same place in memory • Instructions contain addresses • Locations of data • Addresses for instructions (branching) • Logical address - relative to beginning of program • Physical address - actual location in memory (this time) • Automatic conversion using base address • hardware feature designed to meet an OS requirement Rev. by Luciano Gualà (2008)

  38. Paging • Split memory into equal sized, small chunks -page frames • Split programs (processes) into equal sized small chunks - pages • Allocate the required number page frames to a process • Operating System maintains list of free frames • A process does not require contiguous page frames • Use page table to keep track Rev. by Luciano Gualà (2008)

  39. Rev. by Luciano Gualà (2008)

  40. Logical and Physical Addresses - Paging Rev. by Luciano Gualà (2008)

  41. Virtual Memory • Demand paging • Do not require all pages of a process in memory • Bring in pages as required • Page fault • Required page is not in memory • Operating System must swap in required page • May need to swap out a page to make space • Select page to throw out based on recent history Rev. by Luciano Gualà (2008)

  42. Bonus • We do not need all of a process in memory for it to run • We can swap in pages as required • So - we can now run processes that are bigger than total memory available! • Main memory is called real memory • User/programmer sees much bigger memory - virtual memory Rev. by Luciano Gualà (2008)

  43. Thrashing • Too many processes in too little memory • Operating System spends all its time swapping • Little or no real work is done • Disk light is on all the time • Solutions • Good page replacement algorithms • Reduce number of processes running • Fit more memory Rev. by Luciano Gualà (2008)

  44. Some details about paging • Where is the page table (PT) stored? • …in the main memory: • two registers: • Page-table base register (PTBR) • Page-table length register (PTLR) • for each address we have 2 memoy accesses • Usually a cache is used: translation lookaside buffer (TLB) • What can we do if the PT is too big? • two-level paging: paging of the PT • And if there are too many processes? • inverted page table Rev. by Luciano Gualà (2008)

  45. Idea: an entry for each memory frame search is expensive!!! inverted page table Rev. by Luciano Gualà (2008)

  46. …we can use an hash table! Rev. by Luciano Gualà (2008)

  47. Segmentation • Paging is not (usually) visible to the programmer • Segmentation is visible to the programmer • Usually different segments allocated to program and data • May be a number of program and data segments Rev. by Luciano Gualà (2008)

  48. Advantages of Segmentation • Simplifies handling of growing data structures • Lends itself to sharing among processes • Lends itself to protection • Some systems combine segmentation with paging Rev. by Luciano Gualà (2008)

More Related