Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads

Similar presentations


Presentation on theme: "Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads"— Presentation transcript:

1 Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling

2 2.1 Processes 2.1.1 The Process Model
Multiprogramming of four programs Conceptual model of 4 independent, sequential processes Only one program active at any instant

3 2.1.2 Process Creation Principal events that cause process creation
System initialization Foreground: shells interacting with users Background: daemons like telnetd, httpd Execution of a process creation system call UNIX: fork and execv Win32: CreateProcess User request to create a new process Initiation of a batch job

4 2.1.3 Process Termination Conditions which terminate processes
Normal exit (voluntary) Process completes successfully UNIX: exit(), Win32: ExitProcess Error exit (voluntary) Process finds a fatal error and terminates Fatal error (involuntary) Process executes an illegal instruction and the kernel terminates the process Killed by another process (involuntary) UNIX: kill, WIn32: TerminateProcess

5 2.1.4 Process Hierarchies Parent creates a child process, child processes can create its own process Forms a hierarchy UNIX calls this a "process group" Windows has no concept of process hierarchy all processes are created equal

6 2.1.5 Process States Possible process states
running: process is using the CPU blocked: process is waiting for I/O, or event ready: process is waiting for CPU Transitions between states show

7 2.1.6 Implementation of Processes (1)
Fields of a process table entry (PCB)

8 2.1.6 Implementation of Processes (2)
Skeleton of what lowest level of OS does when an interrupt occurs

9 2.2 Threads 2.2.1 The Thread Model (1)
(a) Three processes each with one thread (b) One process with three threads

10 2.2.1 The Thread Model (2) Items shared by all threads in a process
Items private to each thread

11 2.2.1 The Thread Model (3) All threads have the exact same address space Share all global variables, open file, child processes, signals Each thread has its own stack

12 A multithreaded Web server
2.2.2 Thread Usage (2) A multithreaded Web server

13 2.2.2 Thread Usage (3) Rough outline of code for previous slide
(a) Dispatcher thread (b) Worker thread

14 2.2.3 Implementing Threads in User Space
A user-level threads package

15 2.3.4 Implementing Threads in the Kernel
A threads package managed by the kernel

16 2.2.5 Hybrid Implementations
Multiplexing user-level threads onto kernel- level threads


Download ppt "Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads"

Similar presentations


Ads by Google