Presentation is loading. Please wait.

Presentation is loading. Please wait.

Review: Operating System Manages all system resources ALU Memory I/O Files Objectives: Security Efficiency Convenience.

Similar presentations

Presentation on theme: "Review: Operating System Manages all system resources ALU Memory I/O Files Objectives: Security Efficiency Convenience."— Presentation transcript:

1 Review: Operating System Manages all system resources ALU Memory I/O Files Objectives: Security Efficiency Convenience

2 What is a process? Any running program including its context and environment: –Register content –Memory content and address space –PC –State (example: waiting for I/O)

3 Process Management Why process management? –There is only one (or a limited number of) CPU per computer, but most of the time many programs run at the “same” time –Multi user systems such as sales, debit or eureka (UNIX machines of Stern) –All modern computer support multitasking via time slicing –List of current processes Task list on PC after CTR-Alt-Del top command under UNIX

4 Process abstraction and context Any process feels as if he was the only one running on the machine, he does not need to know anything about any other process (unless related) But a processor has a limited amount of physical resources and every process on the machine has its own set of registers. Solution: save and restore hardware state on a context switch. Save the state in Process Control Block (PCB)

5 Process Control Block All information that is associated with a process –Process state (new, ready, waiting …) –PC (Program Counter) how far got the execution –CPU Register content –Memory management information –I/O status –Some accounting (open files …) All this information has to be updated whenever the process changes state: Overhead!

6 Historical Difference UNIX, DOS Uniprogramming: one process at a time Multiprogramming: multiple processes DOS was originally uniprogramming – One key problem with DOS is that there is no memory protection - one program may write the memory of another program, causing weird bugs. Unix plus all currently envisioned new operating systems allow system to separate out activities cleanly

7 Process Creation Parent processes create child processes, which in turn create further child processes Resource sharing –degree of sharing can vary from all to none Execution –concurrently –parent waits for child to terminate –example in UNIX: call child with & option keeps the parent active

8 Process Termination User logs off Quit an application –User interaction –Time limit exceeded Process finished: Normal completion Error –Memory unavailable –Arithmetic error –Security error: Memory or file

9 Process Termination I/O Failure Invalid instruction (you tried to execute data) Operating system intervention (e.g. deadlock) Parent terminates (shell logout) Parent requests termination(kill)

10 Process States During Execution a process changes state –new: The process is being created User calls a program Some program starts another process –running: Instructions are executed –waiting: The process is waiting for an event to occur –ready: The process is waiting to be executed –terminated: The process has finished execution

11 Diagram of Process States newterminated waiting readyrunning I/O or event wait I/O or event completion interrupt admitted exit scheduler

12 Process States Example

13 Memory

14 CPU Switch from Process to Process Save state in PCB0 Save state in PCB1 Load state from PCB1 Load state in PCB0 executing Interrupt idle P0 P1 OS

15 Interrupts Two types: Hardware and Software Hardware interrupts are generated by a physical device Software generated by OS for instance after timeout of running process Interrupt register/bus that communicates interrupt to the control unit of CPU Different Levels –depending on the priority of the current process, lower level interrupts can be ignored –hardware have usually higher priority than software interrupts

16 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 during which the system does no useful work Overhead depends on hardware support Question: You have 6 big job to run on a 2 processor machine. What is the optimal strategy to start them?

17 Scheduling Objectives Fairness –Give equal and fair access to all processes Responsiveness –Discriminate between different classes of jobs Efficiency –Maximize throughput –Minimize response time –Accommodate as many uses as possible

18 Process Scheduling Queues Job queue - all processes in the system Ready queue - all processes residing in main memory ready and waiting to execute Device queue - set of processes waiting for an I/O device Process migration between various queues

19 Two Queues

20 Appendix: UNIX Commands ps: show all processes that were started from this shell –ps -u username : all processes started by user top: show all processes running on the computer kill id : Stop running process with id nohup: make process immune to high level interrupts nice +int process: change the priority of a process man command: get information about command

Download ppt "Review: Operating System Manages all system resources ALU Memory I/O Files Objectives: Security Efficiency Convenience."

Similar presentations

Ads by Google