Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cs561 Presenter: QIAOQIAO CHEN Spring 2012

Similar presentations


Presentation on theme: "Cs561 Presenter: QIAOQIAO CHEN Spring 2012"— Presentation transcript:

1 Cs561 Presenter: QIAOQIAO CHEN Spring 2012
Process Cs561 Presenter: QIAOQIAO CHEN Spring 2012 Process 11/22/2018

2 Lecture Outline Definition of a Process Anatomy of a Process
Process States Context Switch Process Manipulation Thread Process 11/22/2018

3 What is a Process? A Process is an execution stream
A Process is the basic unit of execution Process examples: shell, web browser It needs resources to run (minimum): Memory CPU registers Process 11/22/2018

4 Anatomy of a Process Processes are separated from each other Process
11/22/2018

5 Organization of Processes
Two concepts Uniprogramming – only one process is handled at a time Multiprogramming – multiple processes running at a time Resource Sharing? Process 11/22/2018

6 Process states New (also called created) – process awaits admission to “ready” state. Ready (also called waiting) – waiting for execution on CPU. Running – when it is chosen for execution. Blocked – by some events, such as I/O. Terminated – after execution or explicitly being killed. Process 11/22/2018

7 Context Switch How does OS implement process abstraction?
Key Idea: switch from one process to another Process 11/22/2018

8 Process Manipulation In Unix OS, there functions for process creation, deletion, signaling and controlling. fork(), exec(), wait(), exit(), kill(), sleep(), ptrace(), etc. Process 11/22/2018

9 Process Manipulation continue
Process creation using fork(). Creates a child process that inherits identical copy of all parent’s memory and variables copy identical CUP registers of parent process Fork() return 0 to child, non-zero to parent After fork(), two processes are running at parallel. Why people say fork() is expensive? Process 11/22/2018

10 Fork() continue Example of Unix fork(): Process 11/22/2018

11 Process manipulation continue
Terminate a process after its job done, using exit() Take the results as an argument Close up things Deallocate memory and OS data structures that support this process Checks if parent process is alive: yes – hold the results until parent asks for them (zombie child) no – Deallocate data structure, now the process is dead. Clean up all zombie child processes. Process 11/22/2018

12 Thread A thread is also a stream of execution.
Difference between threads and processes: Thread ≈ function, process ≈ program One thread is bound to one process Multiple threads can access the same memory Context switch in threads? Much cheaper! Process 11/22/2018

13 References Martin C, Rinard, “Process and Threads”, available at “OS structure, Processes & Processes Management”, available at 9.pdf Process 11/22/2018


Download ppt "Cs561 Presenter: QIAOQIAO CHEN Spring 2012"

Similar presentations


Ads by Google