- Running instance of a program (Program : passive ; Process : active)
Process Control Block
- 3 pieces of information about process (ID, Control Info, State Info)
- Identification (PID,UID, Parent PID)
- Control Information (state, scheduling information, priority information)
- State Information (user registers, pc, stack pointer, psw, MM info, files etc)
- Accessible in kernel mode only
- Stored in process tables
Process States and Transitions
State Description
New Process initiated, not running yet and or OS doesn’t know about it
Ready OS knows it's there, puts it in a priority based queue (waiting for CPU)
Running Process being executed by the OS
Blocked Not finished execution but time slice over
Exit Finished execution, terminated
Transition Description
Ready -> Running OS executes process when its time to do so (CPU on that process)
Running -> Blocked Can't continue, goes in a queue till its back to ready state (interrupt)
Running -> Exit Process is terminated, no longer executable
Multiprogramming
- Quickly swapping between processes (perceived parallelism)
- Single Core: concurrent execution
- Multi Core: true parallelism
, Context Switching
- 2 Things happen when a context switch occurs
- 1: Save CPU state, PCB update (for the old process)
- 2: Restore CPU state, PCB read (for the new process)
Sample Visualization: P1->CS->P2->CS->P3…
- Trade Off: length of the time slice vs context switch time
- Steps
- Save the process state (PC, Registers)
- Update PCB (running -> ready/blocked)
- Move that PCB to the correct queue (ready/blocked)
- Run scheduler => selects a new process to run
- In the PCB for the new process, update the state to running
- Update the MMU
- Restore the process (after the time slice finishes)
System Calls
- Function calls (wrapped in OS libraries) ; (these are good coding practices)
- Can have system calls for different functions : Process Creation
- Unix: fork() (generates a new process which is the exact copy of the parent)
- Windows: NTCreateProcess()
- Linux: clone()
Side Note : Unix has exec(), same as fork(), but it will replace instead of keeping current
process
- fork() : Steps
- Creates an exact copy of the parent process
- Returns process ID of child to the parent (iPID > 0)
- Returns 0 to the child process
- No of children created: 2^(No. fork calls) - 1
Process Scheduling
- OS need to schedule processes (uses a scheduler)
- New -> Ready (admits a process into a queue)
- Ready -> Running (decides what to run next)
- Running -> Ready/Blocked (Interrupts)
- Scheduler: decides what process to run next (using some algorithms)
- Type of scheduling algorithm is dependent on the OS
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller rahulravi1. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $20.62. You're not tied to anything after your purchase.