Chapter 3 Notes

Download Report

Transcript Chapter 3 Notes

Process Description and Control
Process
• A program in execution
• OS Reponsibilities:
–
–
–
–
–
Creation/Termination
Scheduling processes
Suspension/resumption
Synchronization, Interprocess communication
Deadlock handling
• Needs
– CPU time, memory, files, I/O devices, etc.
Parallel Execution of processes
• Resource sharing
• Speed up
• Modular design of programs
Process Description
• PCB--Process Control Block (a record
containing following info):
–
–
–
–
–
–
–
Process state-new/ready/running/blocked/halted
Program Counter
CPU register values
Scheduling information
Memory management info
Accounting info
I/O status, other info
Process State Diagram
•
ready
running
Scheduler chooses
Time exceeded
new
I/O done
Needs to to I/O
blocked
terminated
Process Creation
• In Unix, fork() system call
• fork() creates an almost identical copy of
the process
• Child and parent
• if (fork()==0) {child_code} else
{parent_code}
Process termination
• When executing last instruction or killed by
someone else
• Clean up
• Release resources held by the process
• Accounting info to be updated
Process switch
• When to switch?
– Clock interrupt
– I/O interrupt
– memory fault