ch2 - Chapter 2: Processes and Threads Slides derived from...

Info iconThis preview shows pages 1–25. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 2: Processes and Threads Slides derived from Andrew Tanenbaum
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Figure 2-1. (a) Multiprogramming of four programs. (b) Conceptual model of four independent, sequential processes. (c) Only one program is active at once. The Process Model
Background image of page 2
Figure 2-6. CPU utilization as a function of the number of processes in memory. Modeling Multiprogramming
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Events which cause process creation: 1. System initialization. 2. Execution of a process creation system call by a running process. 3. A user request to create a new process. 4. Initiation of a batch job. Process Creation
Background image of page 4
Events which cause process termination: 1. Normal exit (voluntary). 2. Error exit (voluntary). 3. Fatal error (involuntary). 4. Killed by another process (involuntary). Process Termination
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Figure 2-2. A process can be in running, blocked, or ready state. Transitions between these states are as shown. Process States Possible process states: Running Blocked Ready Any others?
Background image of page 6
Figure 2-4. Some of the fields of a typical process table entry. Implementation of Processes
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Context Switching All Registers must be saved to process data structure (table entry). Assembly language used to save registers and put values back into registers. Why not C/C++?
Background image of page 8
Figure 2-5. Skeleton of what the lowest level of the operating system does when an interrupt occurs. Interrupts and Processes
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Foreground, BackGround & Daemons Foreground processes: interacting with user Background processes: running without input from user. What is the significance in windowed systems? Daemons : Wait in background to handle event or activity.
Background image of page 10
Why do we use a two step method in UNIX? if(fork() == 0) execve( . .. ); And only CreateProcess which does both in Windows?
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Process Hierarchies Parent creates a child process, child processes can create its own process Forms a hierarchy UNIX calls this a "process group" All can receive signals Windows has no concept of process hierarchy all processes are created equal
Background image of page 12
Process Organization 1. Process Table 2. Linked List(s) of Process Data structures P1 P2 P3 P1 P2 P3 ...
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Thread Model Separation of resource grouping and execution “Thread of Execution”
Background image of page 14
Threads The Thread Model (a) Three processes each with one thread (b) One process with three threads
Background image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The Thread Model Items shared by all threads in a process Items private to each thread
Background image of page 16
Why do we want threads? Multiple jobs (cooperating) Why can’t we do this with processes? Easier to create and destroy (fast) Performance gain when proper mixture of CPU bound and I/O bound jobs. Multiprocessor systems can use them well
Background image of page 17

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The Thread Model Each thread has its own stack
Background image of page 18
Thread library calls thread_create thread_exit thread_yield Etc.
Background image of page 19

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Thread Usage Example 1 A word processor with three threads
Background image of page 20
Thread Usage Example 2 A multithreaded Web server
Background image of page 21

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Thread Usage Rough outline of code for previous slide (a) Dispatcher thread (b) Worker thread
Background image of page 22
Implementation of Threads In user space In kernel space
Background image of page 23

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Implementing Threads in User Space A user-level threads package THE KERNEL DOES NOT KNOW ABOUT THEM!!!
Background image of page 24
Image of page 25
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/02/2012 for the course CIS 486 taught by Professor Mcsweeney during the Spring '10 term at Syracuse.

Page1 / 102

ch2 - Chapter 2: Processes and Threads Slides derived from...

This preview shows document pages 1 - 25. Sign up to view the full document.

View Full Document Right Arrow Icon