Presentation is loading. Please wait.

Presentation is loading. Please wait.

Processes David Ferry CSCI 3500 – Operating Systems

Similar presentations


Presentation on theme: "Processes David Ferry CSCI 3500 – Operating Systems"— Presentation transcript:

1 Processes David Ferry CSCI 3500 – Operating Systems
Saint Louis University St. Louis, MO 63103

2 CSCI 3500 - Operating Systems
Definition A process is a program in execution A process has internal state that evolves, a program on the hard drive does not You can have multiple copies of the same program executing Processes are the fundamental abstraction for managing a key computer resource: processor time Each process runs independently Allows for pseudo-concurrency by allowing multiple programs to execute “concurrently” CSCI Operating Systems

3 Kernel Process Data Structures
The OS must keep track of all running processes. Process Table Process Control Block (PCB) Process Number (PID) PCB Pointer 1 2 3 4 Program Counter Register File Memory Map Open Files Accounting Info PCB is the largest individual data structure in the Linux kernel, with over a thousand fields. Tracks everything done at a per-process level Program Counter Register File Memory Map Open Files Accounting Info

4 Process State Diagram Blocked Ready Running Initialize Finalize
Input Available/ Event Finished Process Start Process End Blocks for Input Scheduled onto processor Scheduler swaps off Lifecycle of a process: Spends most of its life between ready and running. When a process can’t continue it blocks. Blocking examples: “Press any key to continue” Wait for hard drive to become available Wait for lock/mutex to become available

5 CSCI 3500 - Operating Systems
Multi-Programming The CPU scheduler shares the processor among running processes Single processor Multi-processor Process A Process B Process C Process A Process B Process A Process B Process A Process C Process D Process C Process D Process C CSCI Operating Systems

6 CSCI 3500 - Operating Systems
Context Switch Process A Process B Process C A context switch occurs when the process currently executing on a processor changes. So called because the processor context (program counter, register file) is swapped out. Not apparent from the process point of view. On desktop Linux, commonly happens 1000 times per second. Slower on mobile devices for better battery life. CSCI Operating Systems

7 Context Switch Mechanism
Process Control Block (PCB) CPU Program Counter Register File Program Counter Register File Memory Map Open Files Accounting Info Hardware Clock CPU is executing process in userspace Hardware timer interrupt occurs CPU saves PC and register file in PCB Jumps to Interrupt Service Routine (ISR) ISR saves other process state ISR passes control to OS scheduler OS Scheduler picks next process to run Loads next process state from PCB to processor Process never knows it was interrupted! CSCI Operating Systems


Download ppt "Processes David Ferry CSCI 3500 – Operating Systems"

Similar presentations


Ads by Google