Concepts from chapters 1 & 2 Computer platform consists of a collection of hardware resources Computer applications are developed to perform some task Inefficient for applications to be written directly for a given hardware platform2Concepts from chapters 1 & 2 Operating system provides a convenient to use, feature rich, secure, and consistent interface for applications to use OS provides a uniform, abstract representation of resources that can be requested and accessed by application3Processes A process is a program in execution; process execution must progress in sequential fashion. Can be characterized by its trace. A process requires resources, which are managed by the operating system The OS interleaves the execution of several processes to maximize processor utilization OS supports Inter-Process Communication (IPC) and user creation of processes4Example ExecutionMain MemoryAddressDispatcherProcess AProcess BProcess CProgram Counter010050008000800012000Figure 3.2 Snapshot of Example Execution (Figure 3.4)at Instruction Cycle 135Trace of Process Sequence of instruction that execute for a process Dispatcher switches the processor from one process to another678Time slice ~= 1/10thof a secondProcess state models The OS is responsible for interleaving the execution of the processes. It is important to understand the possible behaviors of all the processes and how to react to them. The behavior of processes is described by means of the process state model.9Two-State Process Model Process may be in one of two states Running Not-running10Queuing Diagram Dispatcher Program that assigns the processor to one process or another Prevents a single process from monopolizing processor time11ProcessorEnterQueueDispatchExitPause(a) Queuing diagram5 Process States As a process executes, it changes state New: The process is being created. Running: Instructions are being executed. Waiting or blocked: The process is waiting for some event to occur. Ready: The process is waiting to be assigned to a process. Terminate or Exit: The process has finished execution.12Diagram of Process State13Process Creation Create a PCB: Set PC, set registers, set state, set process id Type “ps” at prompt to get a list of process ids. Allocate Address space in memory: Main memory is RAM Secondary memory is the hard disk, CD, and floppy Update OS control structures: e.g. Process table, memory tables, I/O tables 14Reason for Process Creation15Reasons for Process Termination16Reasons for Process Termination17Example for 3 Processes18Suspending Processes19Two Suspended States20OS Control Structures21MemoryI/OFileProcessesMemory TablesI/O TablesFile TablesProcess 1Process 2… Process NPrimary TableProcess ImageUser programUser dataSystem stackPCBProcess Control Block (PCB) Information associated with each process. Process ID Process state Program counter (PC) CPU registers (Context data) CPU scheduling information (Priority) Memory-management information (Memory pointer) Accounting information (Time, acct. #) I/O status information (requests, devices assigned)22Process Control Block Contains the process attributes Created and manage by the operating system Allows support for multiple processesProcess = Program code + Data + PCB23Process Control BlockIdentifierFigure 3.1 Simplified Process Control BlockStatePriorityProgram counterMemory pointersContext dataI/O statusinformationAccountinginformation24Process Scheduling Queues Job queue – set of all processes in the system. Ready queue – set of all processes residing in main memory, ready and waiting to execute. Device queues – set of processes waiting for an I/O device. Process migration between the various queues.25Ready Queue, I/O Device Queues26Process Scheduling27Schedulers Long-term scheduler: job scheduler selects which processes should be brought into the ready queue. invoked infrequently (seconds, minutes) controls the degree of multiprogramming Medium-term scheduler allocates memory for process. invoked periodically or as needed. Short-term scheduler: CPU scheduler selects which process should be executed next and allocates CPU. invoked frequently
View Full Document