Download presentation
Presentation is loading. Please wait.
1
Processes A process is a running program.
The cpu can be used by one process while another is waiting on I/O. Multiprogramming – can switch from one program to another (interleave them). To user seems like more than one program running at a time on a single cpu. With a multiprocessor can run more than one at a time.
2
Processes A process is an executing program
with values for program counter, registers and variables. Also owns resources. Example: 3 processes A, B, C C B A Time
3
Processes Must have a scheduling algorithm to
decide when to stop a running process and how to pick another one to run. Processes have different states: New, Running, Ready, Sleeping (wait) Zombie State Child that exited Parent has not called wait() to get exit status Resources have been deallocated Still has entry in process table Can be killed with SIGCHLD (kill -18 ppid) Blocked Process → waiting on resource (I/0 waitpid etc) Ready Running New Exit Sleeping
4
Process Switching During a process switch the state of
the current process must be saved. Then the new process can be given time on the cpu – context switch. The process that was taken off the cpu can be loaded back on some time later. Must save program counter, contents of registers, etc. to do so. Takes some amount of time.
5
Processes OS Must have a way to create and
terminate processes. Start off with initial process (init, pid 1). Then create more processes to form a tree. How to create a process - allocate resources - create process table entry fork(2), ps command, pid, parent pid
6
Processes Processes have three sections. Text section (code) can
be shared between processes Stack Data Text Memory
7
Process Hierarchy - SVR4
0 - sched Use ps and ptree commands 1 - init inetd sshd tcsh
8
Process Termination Normal voluntary exit Error voluntary exit
involuntary fatal error killed by another process free up resources remove process table entry How many processes can a system support?
9
Process Table Array of structures about active processes
- process state - program counter - stack pointer - memory allocation - open files + other stuff Interrupt handling – suspend current process, save registers, etc, run handler then process scheduler.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.