Full Transcript

CS1110 Introduction to Computer Science Chapter 4 Operating Systems (In Book: Chapter 10) 1 Chapter Goals (1 of 2) Describe the two main responsibilities of an operating system Define memory and process management Explain...

CS1110 Introduction to Computer Science Chapter 4 Operating Systems (In Book: Chapter 10) 1 Chapter Goals (1 of 2) Describe the two main responsibilities of an operating system Define memory and process management Explain the relationship between logical and physical addresses Compare and contrast memory management techniques 2 Chapter Goals (2 of 2) Distinguish between fixed and dynamic partitions Define and apply partition selection algorithms Explain the stages and transitions of the process life cycle Explain the processing of various CPU scheduling algorithms 3 Software Categories Modern software can be divided into two categories: Application Software Software written to address specific needs to solve problems in the real world. System Software Software that manages a computer system at a fundamental level. Can you name examples of each? 4 Roles of an Operating System (1 of 2) Operating System System software that: – Manages computer resources, such as memory and input/output devices – Provides an interface through which a human can interact with the computer – Allows an application program to interact with other system resources 5 Roles of an Operating System (2 of 2) An operating system manages resources, and these resources are often shared in one way or another among programs that want to use them 6 Resource Management (1 of 2) Multiprogramming The technique of keeping multiple programs in main memory at the same time; these programs compete for access to the CPU so that they can do their work. Operating systems employ multiprogramming to one degree or another. An operating system must therefore perform memory management to keep track of which programs are in memory and where in memory they reside. Memory Management The process of keeping track of what programs are in memory and where in memory they reside 7 Resource Management (2 of 2) Process A program in execution Process Management The act of carefully tracking the progress of a process and all of its intermediate states CPU Scheduling Determining which process in memory is executed by the CPU at any given point 8 Other OS Factors Real-Time System A system in which response time is crucial given the nature of the application Response Time The time delay between receiving a stimulus and producing a response Device Driver A small program that “knows” the way a particular device expects to receive and deliver information 9 Memory Management Operating systems must employ techniques to: – Track where and how a program resides in memory – Convert logical addresses into physical addresses Logical Address Reference to a stored value relative to the program making the reference Physical Address Actual address in main memory 10 Partition Memory Management (1 of 2) Single contiguous MM has only the OS and one other program in memory at one time Partition MM has the OS and any number of other programs in memory at one time There are two schemes for dividing up memory for programs: – Fixed partitions Main memory is divided into a fixed number of partitions into which programs can be loaded – Dynamic partitions Partitions are created as needed to fit the programs waiting to be loaded 11 Partition Memory Management (2 of 2) Memory is divided into a set of partitions, some empty and some allocated to programs Base Register A register that holds the beginning address of the current partition (the one that is running) Bounds Register A register that holds the length of the current partition 12 Partition Selection Algorithms (1 of 2) Which partition should we allocate to a new program? First fit Allocate program to the first partition big enough to hold it Best fit Allocated program to the smallest partition big enough to hold it Worst fit Allocate program to the largest partition big enough to hold it 13 Partition Selection Algorithms (2 of 2) A: 1000 Requests come in for blocks of the following sizes: 1000, 25, 780, 1300, and 325 B: 700 C: 750 What block will be assigned to each request if the First-fit algorithm is used? D: 1500 Best-fit algorithm is used? Worst-fit algorithm is used? E: 300 (Treat each request as an independent event) F: 350 14 Process Management (1 of 3) Process Management The act of managing the use of the CPU by individual processes Recall that a process is a program in execution 15 Process Management (2 of 3) The Process States What can cause a process to move to the waiting state? The process life cycle 16 Process Management (3 of 3) The Process States: In the new state, a process is being created. A process that has no barriers to its execution is in the ready state. It is waiting for its chance to use the CPU. A process in the running state is currently being executed by the CPU. Its instructions are being processed in the fetch–execute cycle. A process in the waiting state is currently waiting for resources. A process in the terminated state has completed its execution and is no longer active. Note that many processes may be in the ready state or the waiting state at the same time, but only one process can be in the running state. 17 CPU Scheduling (1 of 2) CPU Scheduling The act of determining which process in the ready state should be moved to the running state – Many processes may be in the ready state – Only one process can be in the running state, making progress at any one time Which one gets to move from ready to running? 18 CPU Scheduling (2 of 2) Nonpreemptive Scheduling The currently executing process gives up the CPU voluntarily Preemptive Scheduling The operating system decides to favor another process, preempting the currently executing process Turnaround Time The amount of time between when a process arrives in the ready state the first time and when it exits the running state for the last time 19 CPU Scheduling Algorithms 1. First-Come, First-Served Processes are moved to the CPU in the order in which they arrive in the running state 2. Shortest Job Next Process with shortest estimated running time in the ready state is moved into the running state first 20 First-Come, First-Served 21 Shortest Job Next 22 CPU Scheduling Algorithms Are these scheduling algorithms preemptive or nonpreemptive? Explain. First-Come, First-Served? Shortest Job Next? 23

Use Quizgecko on...
Browser
Browser