Presentation is loading. Please wait.

Presentation is loading. Please wait.

Processes 2 Introduction to Operating Systems: Module 4.

Similar presentations


Presentation on theme: "Processes 2 Introduction to Operating Systems: Module 4."— Presentation transcript:

1 Processes 2 Introduction to Operating Systems: Module 4

2 Process states terminated ready waiting running terminate block dispatch pre-empt wakeup inactive create activate suspend

3 Process states u Inactive (New or Suspended)  Process has been initiated; the OS has not yet allocated it any memory resources  Process has been active, OS needs to reduce the degree of multiprogramming to improve system performance u Ready  Process has some code and data in memory, is eligible to get CPU u Running  The CPU is currently executing code for this process  In single processor system, only one process is running at a time

4 Process states u Waiting (Blocked)  Process is in a queue waiting for some device or system resource u Terminated  Program is done; process resources need to be recovered (accounting)

5 Operations on processes: creation u When a process is created, the operating system updates its data structures to include the new process u Allocation of memory resources does not occur until activation, though the process may be stored on disk u UNIX examples  fork system call creates new process  execve system call used after a fork to replace the process’ memory space with a new program

6 Operations on processes: creation u Reasons for process creation  User logs on  User starts a program  OS creates process to provide a service (e.G., Printer daemon to manage printer)  Program starts another process (e.G., Netscape calls xv to display a picture)

7 Operations on processes: termination u When a process is terminated, the operating system must free its resources and remove it from OS data structures u Reasons for process termination  Normal completion  Arithmetic error, or data misuse (e.G., Wrong type)  Invalid instruction execution  Insufficient memory available, or memory bounds violation  Resource protection error  I/O failure

8 Operations on processes u Preempt a process (running  ready)  Process’ time quantum expires  Higher priority process arrives at the ready queue u Block a process (running  waiting)  begin waiting for I/O, resource u Wakeup a process (waiting  ready)  when notified I/O complete or resource is available

9 Operations on processes u Dispatch a process (ready  running)  Called on process at head of CPU queue after preempt or block u Change the priority of a process  in UNIX, the nice command u Suspend a process (ready  inactive)  Used to reduce the system load during a peak loading situation  Process state is stored on disk u Activate a process (inactive  ready)  Brings a new inactive process into memory  Resumes the execution of a suspended process

10 Swapping u What if memory cannot hold all processes?  Don't allow the creation of more processes  What about existing processes?  Dynamically allocated memory u Some processes need to have their address space written to disk so that others can continue  Such processes are said to be swapped to disk  Modern OSs don't swap out entire processes, they can selective "swap" parts of the address space We'll learn more of this when we study memory management

11 Process control block (PCB) u Representation of a process u Used to save and restore process context u Exact contents are system dependent  May reside in linked lists u When is the PCB read from memory? Written to memory? process state next previous process id program counter registers memory structure open file table etc


Download ppt "Processes 2 Introduction to Operating Systems: Module 4."

Similar presentations


Ads by Google