Слайд 2
![Processes The Process Model Multiprogramming of four programs Conceptual model](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-1.jpg)
Processes
The Process Model
Multiprogramming of four programs
Conceptual model of 4 independent, sequential
processes
Only one program active at any instant
Слайд 3
![Process Creation Principal events that cause process creation System initialization](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-2.jpg)
Process Creation
Principal events that cause process creation
System initialization
Execution of a process
creation system
User request to create a new process
Initiation of a batch job
Слайд 4
![Process Termination Conditions which terminate processes Normal exit (voluntary) Error](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-3.jpg)
Process Termination
Conditions which terminate processes
Normal exit (voluntary)
Error exit (voluntary)
Fatal error (involuntary)
Killed
by another process (involuntary)
Слайд 5
![Process Hierarchies Parent creates a child process, child processes can](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-4.jpg)
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
![Process States (1) Possible process states running blocked ready Transitions between states shown](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-5.jpg)
Process States (1)
Possible process states
running
blocked
ready
Transitions between states shown
Слайд 7
![Process States (2) Lowest layer of process-structured OS handles interrupts,](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-6.jpg)
Process States (2)
Lowest layer of process-structured OS
handles interrupts, scheduling
Above that layer
are sequential processes
Слайд 8
![Implementation of Processes (1) Fields of a process table entry](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-7.jpg)
Implementation of Processes (1)
Fields of a process table entry
Слайд 9
![Implementation of Processes (2) Skeleton of what lowest level of OS does when an interrupt occurs](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-8.jpg)
Implementation of Processes (2)
Skeleton of what lowest level of OS does
when an interrupt occurs
Слайд 10
![Threads The Thread Model (1) (a) Three processes each with](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-9.jpg)
Threads
The Thread Model (1)
(a) Three processes each with one thread
(b) One
process with three threads
Слайд 11
![The Thread Model (2) Items shared by all threads in](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-10.jpg)
The Thread Model (2)
Items shared by all threads in a process
Items
private to each thread
Слайд 12
![The Thread Model (3) Each thread has its own stack](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-11.jpg)
The Thread Model (3)
Each thread has its own stack
Слайд 13
![Thread Usage (1) A word processor with three threads](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-12.jpg)
Thread Usage (1)
A word processor with three threads
Слайд 14
![Thread Usage (2) A multithreaded Web server](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-13.jpg)
Thread Usage (2)
A multithreaded Web server
Слайд 15
![Thread Usage (3) Rough outline of code for previous slide (a) Dispatcher thread (b) Worker thread](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-14.jpg)
Thread Usage (3)
Rough outline of code for previous slide
(a) Dispatcher thread
(b)
Worker thread
Слайд 16
![Thread Usage (4) Three ways to construct a server](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-15.jpg)
Thread Usage (4)
Three ways to construct a server
Слайд 17
![Implementing Threads in User Space A user-level threads package](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-16.jpg)
Implementing Threads in User Space
A user-level threads package
Слайд 18
![Implementing Threads in the Kernel A threads package managed by the kernel](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-17.jpg)
Implementing Threads in the Kernel
A threads package managed by the kernel
Слайд 19
![Hybrid Implementations Multiplexing user-level threads onto kernel- level threads](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-18.jpg)
Hybrid Implementations
Multiplexing user-level threads onto kernel- level threads
Слайд 20
![Scheduler Activations Goal – mimic functionality of kernel threads gain](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-19.jpg)
Scheduler Activations
Goal – mimic functionality of kernel threads
gain performance of user
space threads
Avoids unnecessary user/kernel transitions
Kernel assigns virtual processors to each process
lets runtime system allocate threads to processors
Problem:
Fundamental reliance on kernel (lower layer)
calling procedures in user space (higher layer)
Слайд 21
![Pop-Up Threads Creation of a new thread when message arrives](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-20.jpg)
Pop-Up Threads
Creation of a new thread when message arrives
(a) before message
arrives
(b) after message arrives
Слайд 22
![Making Single-Threaded Code Multithreaded (1) Conflicts between threads over the use of a global variable](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-21.jpg)
Making Single-Threaded Code Multithreaded (1)
Conflicts between threads over the use of
a global variable
Слайд 23
![Making Single-Threaded Code Multithreaded (2) Threads can have private global variables](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-22.jpg)
Making Single-Threaded Code Multithreaded (2)
Threads can have private global variables
Слайд 24
![Interprocess Communication Race Conditions Two processes want to access shared memory at same time](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-23.jpg)
Interprocess Communication
Race Conditions
Two processes want to access shared memory at same
time
Слайд 25
![Critical Regions (1) Four conditions to provide mutual exclusion No](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-24.jpg)
Critical Regions (1)
Four conditions to provide mutual exclusion
No two processes simultaneously
in critical region
No assumptions made about speeds or numbers of CPUs
No process running outside its critical region may block another process
No process must wait forever to enter its critical region
Слайд 26
![Critical Regions (2) Mutual exclusion using critical regions](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-25.jpg)
Critical Regions (2)
Mutual exclusion using critical regions
Слайд 27
![Mutual Exclusion with Busy Waiting (1) Proposed solution to critical](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-26.jpg)
Mutual Exclusion with Busy Waiting (1)
Proposed solution to critical region problem
(a)
Process 0. (b) Process 1.
Слайд 28
![Mutual Exclusion with Busy Waiting (2) Peterson's solution for achieving mutual exclusion](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-27.jpg)
Mutual Exclusion with Busy Waiting (2)
Peterson's solution for achieving mutual exclusion
Слайд 29
![Mutual Exclusion with Busy Waiting (3) Entering and leaving a critical region using the TSL instruction](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-28.jpg)
Mutual Exclusion with Busy Waiting (3)
Entering and leaving a critical region
using the
TSL instruction
Слайд 30
![Sleep and Wakeup Producer-consumer problem with fatal race condition](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-29.jpg)
Sleep and Wakeup
Producer-consumer problem with fatal race condition
Слайд 31
![Semaphores The producer-consumer problem using semaphores](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-30.jpg)
Semaphores
The producer-consumer problem using semaphores
Слайд 32
![Mutexes Implementation of mutex_lock and mutex_unlock](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-31.jpg)
Mutexes
Implementation of mutex_lock and mutex_unlock
Слайд 33
![Monitors (1) Example of a monitor](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-32.jpg)
Monitors (1)
Example of a monitor
Слайд 34
![Monitors (2) Outline of producer-consumer problem with monitors only one](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-33.jpg)
Monitors (2)
Outline of producer-consumer problem with monitors
only one monitor procedure active
at one time
buffer has N slots
Слайд 35
![Monitors (3) Solution to producer-consumer problem in Java (part 1)](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-34.jpg)
Monitors (3)
Solution to producer-consumer problem in Java (part 1)
Слайд 36
![Monitors (4) Solution to producer-consumer problem in Java (part 2)](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-35.jpg)
Monitors (4)
Solution to producer-consumer problem in Java (part 2)
Слайд 37
![Message Passing The producer-consumer problem with N messages](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-36.jpg)
Message Passing
The producer-consumer problem with N messages
Слайд 38
![Barriers Use of a barrier processes approaching a barrier all](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-37.jpg)
Barriers
Use of a barrier
processes approaching a barrier
all processes but one blocked
at barrier
last process arrives, all are let through
Слайд 39
![Dining Philosophers (1) Philosophers eat/think Eating needs 2 forks Pick](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-38.jpg)
Dining Philosophers (1)
Philosophers eat/think
Eating needs 2 forks
Pick one fork at a
time
How to prevent deadlock
Слайд 40
![Dining Philosophers (2) A nonsolution to the dining philosophers problem](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-39.jpg)
Dining Philosophers (2)
A nonsolution to the dining philosophers problem
Слайд 41
![Dining Philosophers (3) Solution to dining philosophers problem (part 1)](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-40.jpg)
Dining Philosophers (3)
Solution to dining philosophers problem (part 1)
Слайд 42
![Dining Philosophers (4) Solution to dining philosophers problem (part 2)](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-41.jpg)
Dining Philosophers (4)
Solution to dining philosophers problem (part 2)
Слайд 43
![The Readers and Writers Problem A solution to the readers and writers problem](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-42.jpg)
The Readers and Writers Problem
A solution to the readers and writers
problem
Слайд 44
![The Sleeping Barber Problem (1)](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-43.jpg)
The Sleeping Barber Problem (1)
Слайд 45
![The Sleeping Barber Problem (2) Solution to sleeping barber problem.](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-44.jpg)
The Sleeping Barber Problem (2)
Solution to sleeping barber problem.
Слайд 46
![Scheduling Introduction to Scheduling (1) Bursts of CPU usage alternate](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-45.jpg)
Scheduling
Introduction to Scheduling (1)
Bursts of CPU usage alternate with periods of
I/O wait
a CPU-bound process
an I/O bound process
Слайд 47
![Introduction to Scheduling (2) Scheduling Algorithm Goals](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-46.jpg)
Introduction to Scheduling (2)
Scheduling Algorithm Goals
Слайд 48
![Scheduling in Batch Systems (1) An example of shortest job first scheduling](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-47.jpg)
Scheduling in Batch Systems (1)
An example of shortest job first scheduling
Слайд 49
![Scheduling in Batch Systems (2) Three level scheduling](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-48.jpg)
Scheduling in Batch Systems (2)
Three level scheduling
Слайд 50
![Scheduling in Interactive Systems (1) Round Robin Scheduling list of](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-49.jpg)
Scheduling in Interactive Systems (1)
Round Robin Scheduling
list of runnable processes
list of
runnable processes after B uses up its quantum
Слайд 51
![Scheduling in Interactive Systems (2) A scheduling algorithm with four priority classes](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-50.jpg)
Scheduling in Interactive Systems (2)
A scheduling algorithm with four priority classes
Слайд 52
![Scheduling in Real-Time Systems Schedulable real-time system Given m periodic](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-51.jpg)
Scheduling in Real-Time Systems
Schedulable real-time system
Given
m periodic events
event i occurs within
period Pi and requires Ci seconds
Then the load can only be handled if
Слайд 53
![Policy versus Mechanism Separate what is allowed to be done](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-52.jpg)
Policy versus Mechanism
Separate what is allowed to be done with how
it is done
a process knows which of its children threads are important and need priority
Scheduling algorithm parameterized
mechanism in the kernel
Parameters filled in by user processes
policy set by user process
Слайд 54
![Thread Scheduling (1) Possible scheduling of user-level threads 50-msec process quantum threads run 5 msec/CPU burst](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96157/slide-53.jpg)
Thread Scheduling (1)
Possible scheduling of user-level threads
50-msec process quantum
threads run 5
msec/CPU burst