1 / 80

Major Requirements of an Operating System

This lecture discusses the major requirements of an operating system, including process management, resource allocation, and interprocess communication.

stiver
Download Presentation

Major Requirements of an Operating System

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. Lecture 3: Processes Operating System Fall 2006

  2. Major Requirements of anOperating System • Interleave the execution of several processes to maximize processor utilization while providing reasonable response time • Allocate resources to processes in conformance with a specific policy while at the same time avoiding deadlock • Support interprocess communication and user creation of processes, both of which may aid in the structuring of applications

  3. Contents • Process Definition • Process States • Process Scheduling • Process Description • Process Control and Operations • Interprocess Communication

  4. Contents • Process Definition • Process States • Process Scheduling • Process Description • Process Control and Operations • Interprocess Communication

  5. Processes - Definition • Also called a job • Execution of an individual program • Process components: • An executable program – text section • The associated data needed by the program • Stack – temporary data (e.g. function parameters, return addresses, and local variables) • Data section – global variables • Heap – memory which is dynamically allocated during process run time • The execution context of the program • All information the operating system needs to manage the process • Including the value of program counter and the contents of the processor’s registers

  6. Process in memory

  7. Process Trace • Processes can be traced • For a program to be executed, a process is created for that program. • We can characterize the behavior of an individual process by listing the sequence of instructions that execute for that process. • Such a listing is called a trace of the process. • We can characterizing behavior of the processor by showing how the traces of the various processes are interleaved.

  8. Example for processes tracing

  9. Process A OS Process B OS Process C OS Process A OS Process C time

  10. Example for processes tracing (cont.)

  11. Contents • Process Definition • Process States • Process Scheduling • Process Description • Process Control and Operations • Interprocess Communication

  12. Process State - Two-State Process Model • Process may be in one of two states • Running • Not-running

  13. Not-Running Process in a Queue

  14. Process State • Not-running • ready to execute • Waiting (also called blocked) • waiting for I/O • Dispatcher cannot just select the process that has been the longest in the queue because it may be blocked

  15. Process State - A Five-State Model • New: The process is being created • Running: Instructions are being executed • Waiting (blocked): The process is waiting for some event to occur • Ready: The process is waiting to be assigned to a processor • Terminated: The process has finished execution

  16. Process State - A Five-State Model

  17. Queueing-Diagram Representation of Five-State Model

  18. Queueing-Diagram Representation of Five-State Model

  19. Suspended Process – The Need for Swapping • The three principal states just described (Ready, Running, Waiting/Blocked) provide a systematic way of modeling the behavior of processes and guide the implementation of the OS. • However, there is good justification for adding other states to the model – the need for swapping

  20. Suspended Process – The Need for Swapping • Processor is faster than I/O so all processes could be waiting for I/O • Swap these processes to disk to free up more memory • Waiting(Blocked) state becomes suspend state when swapped to disk • Two new states • Waiting(Blocked), suspend • Ready, suspend

  21. One Suspend State

  22. Two Suspend States

  23. Reasons for Process Suspension

  24. Contents • Process Definition • Process Trace • Process States • Process Scheduling • Process Description • Process Control and Operations • Interprocess Communication

  25. Process 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 • Processes migrate among the various queues

  26. Representation of Process Scheduling (Five-State Model)

  27. Schedulers • Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready queue • Short-term scheduler (or CPU scheduler) – selects which process should be executed next and allocates CPU • Medium-term scheduler– corresponds to suspended state (swapping out of the memory)

  28. Addition of Medium Term Scheduling

  29. Schedulers (Cont.) • Short-term scheduler is invoked very frequently (milliseconds)  (must be fast) • Long-term scheduler is invoked very infrequently (seconds, minutes)  (may be slow) • The long-term scheduler controls the degree of multiprogramming • Processes can be described as either: • I/O-bound process – spends more time doing I/O than computations, many short CPU bursts • CPU-bound process – spends more time doing computations; few very long CPU bursts

  30. Context Switch • When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process • Context-switch time is overhead; the system does no useful work while switching • Time dependent on hardware support

  31. Contents • Process Definition • Process States • Process Scheduling • Process Description • Process Control and Operations • Interprocess Communication

  32. What information does the OS need to control processes and manage resources for them?

  33. Memory Tables • Used to keep track of both main(real) and secondary memory. • Must include the following information: • Allocation of main memory to processes. • Allocation of secondary memory to processes. • Protection attributes of blocks of main or virtual memory, such as which processes may access certain shared memory regions. • Information needed to manage virtual memory.

  34. I/O Tables • Used by the OS to manage the I/O devices. • May include the following information: • I/O device is available or assigned • Status of I/O operation • Location in main memory being used as the source or destination of the I/O transfer

  35. File Tables • Provide information about the existence of files: • Existence of files • Location on secondary memory • Current Status • Attributes • Sometimes this information is maintained by a file-management system

  36. Process Tables • Used to manage processes • Include the following information: • Where process is located • Depend on the memory management scheme being used. • In the simplest case, the process image is maintained as a contiguous block of memory. This block is maintained in secondary memory, usually disk. • Attributes necessary for its management • Process ID • Process state • Location in memory

  37. Typically Elements of a Process Image • User Data • The modifiable part of the user space. • May include program data, a user stack area, and programs that may be modified. • User Program • The program to be executed • System Stack • Each process has one or more system stacks associated with it. • A stack is used to store parameters and calling addresses for procedure and system calls. • Process Control Block • Data needed by the OS to control the process.

  38. Process Control Block • Process Identification • Processor State Information • Process Control Information

  39. Process Control Block • Process Identification • Processor State Information • Process Control Information

  40. Process identification • Numeric identifiers that may be stored with the process control block include • Identifier of this process • Identifier of the process that created this process (parent process) • User identifier

  41. Process Control Block • Process Identification • Processor State Information • Process Control Information

  42. Processor State Information • User-Visible Registers • Control and Status Registers • PC • PSW • Stack Pointers • Each process has one or more system stacks associated with it.

  43. Process Control Block • Process Identification • Processor State Information • Process Control Information

  44. Process Control Information • Scheduling and State Information: • Process State (e.g. running, ready, waiting, etc.) • Priority • Scheduling-related information • Depend on the scheduling algorithm used. • e.g. amount of time it has already run, how long it has waited • Event • Identity of event the process is awaiting

  45. Process Control Information (cont.) • Data Structuring • A process may be linked to other processes, e.g to its parent • Interprocess Communication • Various flags, signals, and messages may be associated with communication between two independent processes. • Process Privilege • Processes are granted privileges in terms of the memory that may be accessed and the types of instructions that may be executed.

  46. Process Control Information (cont.) • Memory Management • Including pointers to segment and/or page tables that describe the virtual memory assigned to this process. • Resource Ownership and Utilization • Resources controlled by the process may be indicated, such as opened files. • A history of utilization of the processor or other resources may also be included; this information may be needed by the scheduler.

  47. Contents • Process Definition • Process States • Process Scheduling • Process Description • Process Control and Operations • Interprocess Communication

  48. Process Creation • When a new process is to be added to those currently being managed, the OS builds the date structures that are used to manage the process and allocates address space in main memory to the process. These actions constitute the creation of a new process.

  49. Reasons for Process Creation • Submission of a new batch job • The OS is provided with a batch job control stream usually a tape or disk • Interactive logon • A user at a terminal logs on to the system • Created by OS to provide a service such as printing • The OS can create a process to perform a function on behalf of a user program • Spawned by existing process • For purposes of modularity or to exploit parallalism, a user program can dictate the creation of a number of processes. • When one process spawns another process, the former is called the parent and the spawned process as the child.

More Related