PDF Ccccsss PDF
PDF Ccccsss PDF
PDF Ccccsss PDF
Operating System Concepts – 9th Edit9on Silberschatz, Galvin and Gagne ©2013
What is an Operating System?
Operating System Concepts – 9th Edition 1.2 Silberschatz, Galvin and Gagne ©2013
Computer System Structure
Operating System Concepts – 9th Edition 1.3 Silberschatz, Galvin and Gagne ©2013
Four Components of a Computer System
Operating System Concepts – 9th Edition 1.4 Silberschatz, Galvin and Gagne ©2013
Operating System Definition
OS is a resource allocator
Manages all resources
Decides between conflicting requests for efficient and
fair resource use
OS is a control program
Controls execution of programs to prevent errors and
improper use of the computer
OS is a Command Executer
Provides an environment for running user commands
Operating System Concepts – 9th Edition 1.5 Silberschatz, Galvin and Gagne ©2013
Computer Startup
bootstrap program is loaded at power-up or reboot
Typically stored in ROM or EPROM, generally known as firmware
Initializes all aspects of system
Loads operating system kernel and starts execution
Operating System Concepts – 9th Edition 1.6 Silberschatz, Galvin and Gagne ©2013
Computer System Organization
Computer-system operation
One or more CPUs, device controllers connect through common
bus providing access to shared memory
Concurrent execution of CPUs and devices competing for
memory cycles
Operating System Concepts – 9th Edition 1.7 Silberschatz, Galvin and Gagne ©2013
Computer-System Operation
Operating System Concepts – 9th Edition 1.8 Silberschatz, Galvin and Gagne ©2013
Common Functions of Interrupts
Operating System Concepts – 9th Edition 1.9 Silberschatz, Galvin and Gagne ©2013
Storage Definitions and Notation Review – self read
The basic unit of computer storage is the bit. A bit can contain one of two
values, 0 and 1. All other storage in a computer is based on collections of bits.
Given enough bits, it is amazing how many things a computer can represent:
numbers, letters, images, movies, sounds, documents, and programs, to name
a few. A byte is 8 bits, and on most computers it is the smallest convenient
chunk of storage. For example, most computers don’t have an instruction to
move a bit but do have one to move a byte. A less common term is word,
which is a given computer architecture’s native unit of data. A word is made up
of one or more bytes. For example, a computer that has 64-bit registers and 64-
bit memory addressing typically has 64-bit (8-byte) words. A computer executes
many operations in its native word size rather than a byte at a time.
Computer storage, along with most computer throughput, is generally measured
and manipulated in bytes and collections of bytes.
A kilobyte, or KB, is 1,024 bytes
a megabyte, or MB, is 1,0242 bytes
a gigabyte, or GB, is 1,0243 bytes
a terabyte, or TB, is 1,0244 bytes
a petabyte, or PB, is 1,0245 bytes
Computer manufacturers often round off these numbers and say that a
megabyte is 1 million bytes and a gigabyte is 1 billion bytes. Networking
measurements are an exception to this general rule; they are given in bits
(because networks move data a bit at a time).
Operating System Concepts – 9th Edition 1.10 Silberschatz, Galvin and Gagne ©2013
Storage Structure
Main memory – only large storage media that the CPU can access
directly
Random access
Typically volatile
Secondary storage – extension of main memory that provides large
nonvolatile storage capacity
Hard disks – rigid metal or glass platters covered with magnetic
recording material
Disk surface is logically divided into tracks, which are subdivided into
sectors
The disk controller determines the logical interaction between the device
and the computer
Solid-state disks – faster than hard disks, nonvolatile
Various technologies
Becoming more popular
Operating System Concepts – 9th Edition 1.11 Silberschatz, Galvin and Gagne ©2013
Storage Hierarchy
Operating System Concepts – 9th Edition 1.12 Silberschatz, Galvin and Gagne ©2013
Storage-Device Hierarchy
Operating System Concepts – 9th Edition 1.13 Silberschatz, Galvin and Gagne ©2013
Caching
Operating System Concepts – 9th Edition 1.14 Silberschatz, Galvin and Gagne ©2013
Question
Operating System Concepts – 9th Edition 1.15 Silberschatz, Galvin and Gagne ©2013
Operating System Structure
Multiprogramming (Batch system) needed for efficiency
Goal keep CPU and I/O devices busy at all times
Multiprogramming organizes jobs (code and data) so CPU always has one
to execute
A subset of total jobs in system is kept in memory
Operating System Concepts – 9th Edition 1.16 Silberschatz, Galvin and Gagne ©2013
Operating System Structure
Timesharing (multitasking) is logical extension of multiprogramming.
Operating System Concepts – 9th Edition 1.17 Silberschatz, Galvin and Gagne ©2013
Computer-System Architecture
Multiprocessors
Also known as parallel systems, tightly-coupled systems
Advantages include:
1. Increased throughput
2. Economy of scale
3. Increased reliability – graceful degradation or fault tolerance
Operating System Concepts – 9th Edition 1.18 Silberschatz, Galvin and Gagne ©2013
Clustered Systems
Operating System Concepts – 9th Edition 1.19 Silberschatz, Galvin and Gagne ©2013
Clustered Systems
Operating System Concepts – 9th Edition 1.20 Silberschatz, Galvin and Gagne ©2013
Question
Operating System Concepts – 9th Edition 1.21 Silberschatz, Galvin and Gagne ©2013
Transition from User to Kernel Mode
Timer to prevent infinite loop / process hogging resources
Timer is set to interrupt the computer after some time period
Keep a counter that is decremented by the physical clock.
Operating system set the counter (privileged instruction)
When counter zero generate an interrupt
Set up before scheduling process to regain control or terminate
program that exceeds allotted time
Operating System Concepts – 9th Edition 1.22 Silberschatz, Galvin and Gagne ©2013
Process Management
A process is a program in execution. It is a unit of work within the
system. Program is a passive entity, process is an active entity.
Process needs resources to accomplish its task
CPU, memory, I/O, files
Initialization data
Process termination requires reclaim of any reusable resources
Each process has program counter specifying location of next
instruction to execute
Process executes instructions sequentially, one at a time,
until completion
Typically system has many processes, some user, some
operating system running concurrently on one or more CPUs
Concurrency by multiplexing the CPUs among the processes
Operating System Concepts – 9th Edition 1.23 Silberschatz, Galvin and Gagne ©2013
Process Management Activities
Operating System Concepts – 9th Edition 1.24 Silberschatz, Galvin and Gagne ©2013
Memory Management
Operating System Concepts – 9th Edition 1.25 Silberschatz, Galvin and Gagne ©2013
Storage Management
OS provides uniform, logical view of information storage
Abstracts physical properties to logical storage unit - file
Each medium is controlled by device (i.e., disk drive, tape drive)
Varying properties include access speed, capacity, data-
transfer rate, access method (sequential or random)
File-System management
Files usually organized into directories
Access control on most systems to determine who can access
what
OS activities include
Creating and deleting files and directories
Operating System Concepts – 9th Edition 1.26 Silberschatz, Galvin and Gagne ©2013
Mass-Storage Management
Usually disks used to store data that does not fit in main memory or
data that must be kept for a “long” period of time
Proper management is of central importance
Entire speed of computer operation hinges on disk subsystem and its
algorithms
OS activities
Free-space management
Storage allocation
Disk scheduling
Some storage need not be fast
Tertiary storage includes optical storage, magnetic tape
Still must be managed – by OS or applications
Varies between WORM (write-once, read-many-times) and RW
(read-write)
Operating System Concepts – 9th Edition 1.27 Silberschatz, Galvin and Gagne ©2013
Protection and Security
Operating System Concepts – 9th Edition 1.28 Silberschatz, Galvin and Gagne ©2013
Question
Operating System Concepts – 9th Edition 1.29 Silberschatz, Galvin and Gagne ©2013
Computing Environments - Mobile
Operating System Concepts – 9th Edition 1.30 Silberschatz, Galvin and Gagne ©2013
Computing Environments – Distributed
Distributed computiing
Collection of separate, possibly heterogeneous, systems
networked together
Network is a communications path, TCP/IP most
common
– Local Area Network (LAN)
– Wide Area Network (WAN)
– Metropolitan Area Network (MAN)
– Personal Area Network (PAN)
Network Operating System provides features between
systems across network
Communication scheme allows systems to exchange
messages
Illusion of a single system
Operating System Concepts – 9th Edition 1.31 Silberschatz, Galvin and Gagne ©2013
Computing Environments - Virtualization
Operating System Concepts – 9th Edition 1.32 Silberschatz, Galvin and Gagne ©2013
Computing Environments - Virtualization
Operating System Concepts – 9th Edition 1.33 Silberschatz, Galvin and Gagne ©2013
Computing Environments – Cloud Computing
Operating System Concepts – 9th Edition 1.34 Silberschatz, Galvin and Gagne ©2013
Computing Environments – Real-Time Embedded Systems
Operating System Concepts – 9th Edition 1.35 Silberschatz, Galvin and Gagne ©2013
Open-Source Operating Systems
Operating System Concepts – 9th Edition 1.36 Silberschatz, Galvin and Gagne ©2013
Chapter 6: Process
Synchronization
Operating System Concepts – 9th Edition Silberschatz, Galvin and Gagne ©2013
Background
Save Load
6.2
The concept of producer-consumer
Producer Consumer
in out
count
6.3
What to do in the producer if the
buffer is full?
What to do in the consumer if the
buffer is empty?
6.4
Producer
while (true) {
6.5
Consumer
while (true) {
while (count == 0) Stuck in infinite loop until one item is in
; // do nothing the buffer
nextConsumed = buffer[out];
out = (out + 1) % BUFFER_SIZE;
count--;
6.6
Race Condition
Process 1 Process 2
6.7
Race Condition
count++ could be implemented as
register2 = count
register2 = register2 - 1
count = register2
Consider this execution interleaving with “count = 5” initially:
S0: producer execute register1 = count {register1 = 5}
S1: producer execute register1 = register1 + 1 {register1 = 6}
S2: consumer execute register2 = count {register2 = 5}
S3: consumer execute register2 = register2 - 1 {register2 = 4}
S4: producer execute count = register1 {count = 6 }
S5: consumer execute count = register2 {count = 4}
6.8
Question
6.9
Question
6.10
General structure of a typical process P
6.11
Solution to Critical-Section Problem
6.12
Peterson’s Solution
6.13
Algorithm for Process Pi
while (true) {
flag[i] = TRUE;
Give chance to each P; enters its critical section only if either flag[j] == false
another process first turn = j; or turn == i
while ( flag[j] && turn == j);
flag[i] = FALSE;
REMAINDER SECTION
6.14
turn flag
6.15
How this algorithm satisfies the 3
conditions of critical section solution?
6.16
Synchronization Hardware
6.17
TestAndndSet Instruction
Definition:
boolean TestAndSet (boolean *target) Pointer which points to the boolean variable
{
boolean rv = *target;
*target = TRUE;
return rv:
}
6.18
Solution using TestAndSet
// critical section
// remainder section
} 6.19
3- while is false, means exit the loop
and enter CS 1-Pi start with testandset(false) 4- Pj testandset(true
lock
Definition:
6.21
Solution using Swap
Shared Boolean variable lock initialized to FALSE; Each
process has a local Boolean variable key.
Solution:
while (true) {
key = TRUE;
while ( key == TRUE) Stuck in infinite loop until key is false
Swap (&lock, &key );
// critical section
lock = FALSE;
// remainder section
}
6.22
5- stuck in infinite loop, key will remain true
2- while is true, then swap lock and key.
1- lock is initially false for all processes
4- Pj key is true
and lock is true
lock
Operating System Concepts – 9th Edition Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition 7.2 Silberschatz, Galvin and Gagne ©2013
System Model
Operating System Concepts – 9th Edition 7.3 Silberschatz, Galvin and Gagne ©2013
Deadlock Characterization
Operating System Concepts – 9th Edition 7.4 Silberschatz, Galvin and Gagne ©2013
We need a way to present the processes
and the resources in the system.
Operating System Concepts – 9th Edition 7.5 Silberschatz, Galvin and Gagne ©2013
Resource-Allocation Graph
Operating System Concepts – 9th Edition 7.6 Silberschatz, Galvin and Gagne ©2013
Resource-Allocation Graph (Cont.)
Process
Pi requests instance of Rj
Pi
Rj
Pi is holding an instance of Rj
Pi
Rj
Operating System Concepts – 9th Edition 7.7 Silberschatz, Galvin and Gagne ©2013
Question
Operating System Concepts – 9th Edition 7.8 Silberschatz, Galvin and Gagne ©2013
Example of a Resource Allocation Graph
Operating System Concepts – 9th Edition 7.9 Silberschatz, Galvin and Gagne ©2013
How to know if the system is deadlock free?
Operating System Concepts – 9th Edition 7.10 Silberschatz, Galvin and Gagne ©2013
Summary
no cycles no deadlock
Operating System Concepts – 9th Edition 7.11 Silberschatz, Galvin and Gagne ©2013
Resource Allocation Graph With A Deadlock
Is this system
deadlock free?
Operating System Concepts – 9th Edition 7.12 Silberschatz, Galvin and Gagne ©2013
Graph With A Cycle But No Deadlock
Is this system
deadlock free?
Operating System Concepts – 9th Edition 7.13 Silberschatz, Galvin and Gagne ©2013
Methods for Handling Deadlocks
Allow the system to enter a deadlock state and then recover, how?
Ignore the problem and pretend that deadlocks never occur in the
system; used by most operating systems, including Windows and
UNIX. What to do if deadlock happened?
Operating System Concepts – 9th Edition 7.14 Silberschatz, Galvin and Gagne ©2013
Deadlock Prevention
Operating System Concepts – 9th Edition 7.15 Silberschatz, Galvin and Gagne ©2013
Deadlock Prevention (Cont.)
No Preemption – Steps to ensure that
If a process that is holding some resources requests another
resource that cannot be immediately allocated to it, then all
resources currently being held are released
Preempted resources are added to the list of resources for which
the process is waiting
Process will be restarted only when it can regain its old resources,
as well as the new ones that it is requesting
Operating System Concepts – 9th Edition 7.16 Silberschatz, Galvin and Gagne ©2013
Circular wait
For example: If the set of resource types R includes tape drives, disk
drives, and printers, then a function F might be defined as follows:
F(tape drive)= 1; F(disk drive)= 5; F(Printer)= 12.
Operating System Concepts – 9th Edition 7.17 Silberschatz, Galvin and Gagne ©2013
Circular wait
For example: If the set of resource types R includes tape drives, disk
drives, and printers, then a function F might be defined as follows:
F(tape drive)= 1; F(disk drive)= 5; F(Printer)= 12.
Simplest and most useful model requires that each process declare
the maximum number of resources of each type that it may need
Operating System Concepts – 9th Edition 7.19 Silberschatz, Galvin and Gagne ©2013
Safe State
That is:
If Pi resource needs are not immediately available, then Pi can
wait until all Pj have finished
When Pj is finished, Pi can obtain needed resources, execute,
return allocated resources, and terminate
When Pi terminates, Pi +1 can obtain its needed resources, and so
on
Operating System Concepts – 9th Edition 7.20 Silberschatz, Galvin and Gagne ©2013
The system knows each process:
resources max need
resources currently held.
Check if there is a safe state by allocating the
needed resources in the future :
Possible future need = Max Need - Current Hold
Free resources = total resources – total currently held
Operating System Concepts – 9th Edition 7.21 Silberschatz, Galvin and Gagne ©2013
Is the current allocation safe, if yes what is
the safe sequence?
Operating System Concepts – 9th Edition 7.22 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition 7.23 Silberschatz, Galvin and Gagne ©2013
Total 12 resources available
Is the current allocation safe, if yes
what is the safe sequence?
Operating System Concepts – 9th Edition 7.24 Silberschatz, Galvin and Gagne ©2013
Even if P1 take the remaining free resources (2) and completes its
execution (release all its 4 resources). P0 and P2 Future need is 5
and 6 which cannot be fullfilled.
Operating System Concepts – 9th Edition 7.25 Silberschatz, Galvin and Gagne ©2013
Basic Facts
Operating System Concepts – 9th Edition 7.26 Silberschatz, Galvin and Gagne ©2013
Avoidance algorithms
Operating System Concepts – 9th Edition 7.27 Silberschatz, Galvin and Gagne ©2013
Resource-Allocation Graph Scheme
Operating System Concepts – 9th Edition 7.28 Silberschatz, Galvin and Gagne ©2013
Resource-Allocation Graph
Operating System Concepts – 9th Edition 7.29 Silberschatz, Galvin and Gagne ©2013
Unsafe State In Resource-Allocation Graph
Operating System Concepts – 9th Edition 7.30 Silberschatz, Galvin and Gagne ©2013
Resource-Allocation Graph Algorithm
Operating System Concepts – 9th Edition 7.31 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition 7.32 Silberschatz, Galvin and Gagne ©2013
Question
Operating System Concepts – 9th Edition 7.33 Silberschatz, Galvin and Gagne ©2013
Chapter 4: Threads
Operating System Concepts – 9th Edition Silberschatz, Galvin and Gagne ©2013
Single and Multithreaded Processes
Operating System Concepts – 9th Edition 4.2 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition 4.3 Silberschatz, Galvin and Gagne ©2013
Benefits
Responsiveness
Resource Sharing
Economy
Scalability
Operating System Concepts – 9th Edition 4.4 Silberschatz, Galvin and Gagne ©2013
Question
What is the difference between fork and thread?
Operating System Concepts – 9th Edition 4.5 Silberschatz, Galvin and Gagne ©2013
Multicore Programming
Multicore systems putting pressure on programmers, challenges include
Dividing activities
Balance
Data splitting
Data dependency
Testing and debugging
Operating System Concepts – 9th Edition 4.6 Silberschatz, Galvin and Gagne ©2013
Multithreaded Server Architecture
Operating System Concepts – 9th Edition 4.7 Silberschatz, Galvin and Gagne ©2013
Concurrent Execution on a Single-core System
Operating System Concepts – 9th Edition 4.8 Silberschatz, Galvin and Gagne ©2013
Parallel Execution on a Multicore System
Operating System Concepts – 9th Edition 4.9 Silberschatz, Galvin and Gagne ©2013
User Threads
Thread management done by user-level threads library
Operating System Concepts – 9th Edition 4.10 Silberschatz, Galvin and Gagne ©2013
Multithreading Models
Many-to-One
One-to-One
Many-to-Many
Operating System Concepts – 9th Edition 4.11 Silberschatz, Galvin and Gagne ©2013
Many-to-One
Many user-level threads mapped to single kernel thread
Examples:
Solaris Green Threads
GNU Portable Threads
Operating System Concepts – 9th Edition 4.12 Silberschatz, Galvin and Gagne ©2013
Many-to-One Model
Operating System Concepts – 9th Edition 4.13 Silberschatz, Galvin and Gagne ©2013
One-to-One
Each user-level thread maps to kernel thread
Examples
Windows NT/XP/2000
Linux
Solaris 9 and later
Operating System Concepts – 9th Edition 4.14 Silberschatz, Galvin and Gagne ©2013
One-to-one Model
Operating System Concepts – 9th Edition 4.15 Silberschatz, Galvin and Gagne ©2013
Many-to-Many Model
Operating System Concepts – 9th Edition 4.16 Silberschatz, Galvin and Gagne ©2013
Many-to-Many Model
Operating System Concepts – 9th Edition 4.17 Silberschatz, Galvin and Gagne ©2013
Question
Under what circumstances do we use multithreading?
Operating System Concepts – 9th Edition 4.18 Silberschatz, Galvin and Gagne ©2013
Pthreads
May be provided either as user-level or kernel-level
A POSIX standard (IEEE 1003.1c) API for thread creation and synchronization
API specifies behavior of the thread library, implementation is up to development of the
library
Common in UNIX operating systems (Solaris, Linux, Mac OS X)
Operating System Concepts – 9th Edition 4.19 Silberschatz, Galvin and Gagne ©2013
Java Threads
Java threads are managed by the JVM
Operating System Concepts – 9th Edition 4.20 Silberschatz, Galvin and Gagne ©2013
Threading Issues
Operating System Concepts – 9th Edition 4.21 Silberschatz, Galvin and Gagne ©2013
Semantics of fork() and exec()
Does fork() duplicate only the calling thread or all threads?
Operating System Concepts – 9th Edition 4.22 Silberschatz, Galvin and Gagne ©2013
Thread Cancellation
Operating System Concepts – 9th Edition 4.23 Silberschatz, Galvin and Gagne ©2013
Signal Handling
Signals are used in UNIX systems to notify a process that a particular event has occurred
A signal handler is used to process signals
1. Signal is generated by particular event
2. Signal is delivered to a process
3. Signal is handled
Options:
Deliver the signal to the thread to which the signal applies
Deliver the signal to every thread in the process
Deliver the signal to certain threads in the process
Assign a specific thread to receive all signals for the process
Operating System Concepts – 9th Edition 4.24 Silberschatz, Galvin and Gagne ©2013
Online compiler that support threads
https://rextester.com/AWD84754
Operating System Concepts – 9th Edition 4.25 Silberschatz, Galvin and Gagne ©2013
Chapter 8: Main Memory
Operating System Concepts – 8th Edition Silberschatz, Galvin and Gagne ©2009
Background
Program must be brought (from disk) into memory and placed within a
process for it to be run
Main memory and registers are only storage CPU can access directly
Operating System Concepts – 8th Edition 8.2 Silberschatz, Galvin and Gagne ©2009
Base and Limit Registers
A pair of base and limit registers define the logical address space
Operating System Concepts – 8th Edition 8.3 Silberschatz, Galvin and Gagne ©2009
Logical vs. Physical Address Space
Logical and physical addresses are the same in compile-time and load-
time address-binding schemes; logical (virtual) and physical addresses
differ in execution-time address-binding scheme
Operating System Concepts – 8th Edition 8.4 Silberschatz, Galvin and Gagne ©2009
Question
Operating System Concepts – 8th Edition 8.5 Silberschatz, Galvin and Gagne ©2009
Memory-Management Unit (MMU)
The user program deals with logical addresses; it never sees the real
physical addresses
Operating System Concepts – 8th Edition 8.6 Silberschatz, Galvin and Gagne ©2009
Dynamic relocation using a
relocation register
Operating System Concepts – 8th Edition 8.7 Silberschatz, Galvin and Gagne ©2009
Swapping
A process can be swapped temporarily out of memory to a backing
store, and then brought back into memory for continued execution
Major part of swap time is transfer time; total transfer time is directly
proportional to the amount of memory swapped
Operating System Concepts – 8th Edition 8.8 Silberschatz, Galvin and Gagne ©2009
Schematic View of Swapping
Operating System Concepts – 8th Edition 8.9 Silberschatz, Galvin and Gagne ©2009
Contiguous Allocation
Operating System Concepts – 8th Edition 8.10 Silberschatz, Galvin and Gagne ©2009
Hardware Support for Relocation
and Limit Registers
Operating System Concepts – 8th Edition 8.11 Silberschatz, Galvin and Gagne ©2009
Contiguous Allocation (Cont.)
Multiple-partition allocation
Hole – block of available memory; holes of various size are
scattered throughout memory
When a process arrives, it is allocated memory from a hole large
enough to accommodate it
Operating system maintains information about:
a) allocated partitions b) free partitions (hole)
OS OS OS OS
process 8 process 10
Operating System Concepts – 8th Edition 8.12 Silberschatz, Galvin and Gagne ©2009
Dynamic Storage-Allocation Problem
Best-fit: Allocate the smallest hole that is big enough; must search
entire list, unless ordered by size
Produces the smallest leftover hole
Worst-fit: Allocate the largest hole; must also search entire list
Produces the largest leftover hole
First-fit and best-fit better than worst-fit in terms of speed and storage
utilization
Operating System Concepts – 8th Edition 8.13 Silberschatz, Galvin and Gagne ©2009
Dynamic Storage-Allocation Problem
(cont.)
Exercise:
Given memory partitions of 100kb, 500kb, 200kb,
300kb and 600kb (in order), how would each of first
fit, best fit and worst fit algorithms place processes
of 212kb, 417kb, 112kb, and 426kb (in order)? Which
algorithm makes the most efficient use of memory?
Operating System Concepts – 8th Edition 8.14 Silberschatz, Galvin and Gagne ©2009
Fragmentation
Operating System Concepts – 8th Edition 8.15 Silberschatz, Galvin and Gagne ©2009
Operating System Concepts – 8th Edition 8.16 Silberschatz, Galvin and Gagne ©2009
Paging
Logical address space of a process can be noncontiguous; process is
allocated physical memory whenever the latter is available
To run a program of size n pages, need to find n free frames and load
program
Internal fragmentation
Operating System Concepts – 8th Edition 8.17 Silberschatz, Galvin and Gagne ©2009
Address Translation Scheme
Operating System Concepts – 8th Edition 8.18 Silberschatz, Galvin and Gagne ©2009
You need to know
Operating System Concepts – 8th Edition 8.19 Silberschatz, Galvin and Gagne ©2009
Paging Hardware
Operating System Concepts – 8th Edition 8.20 Silberschatz, Galvin and Gagne ©2009
Paging Model of Logical and
Physical Memory
Operating System Concepts – 8th Edition 8.21 Silberschatz, Galvin and Gagne ©2009
Example
4-byte page size.
32-byte physical memory.
logical-address space is 16.
Operating System Concepts – 8th Edition 8.22 Silberschatz, Galvin and Gagne ©2009
Paging Example
Operating System Concepts – 8th Edition 8.24 Silberschatz, Galvin and Gagne ©2009
Operating System Concepts – 8th Edition 8.25 Silberschatz, Galvin and Gagne ©2009
Questions
Operating System Concepts – 8th Edition 8.26 Silberschatz, Galvin and Gagne ©2009
Questions
Operating System Concepts – 8th Edition 8.27 Silberschatz, Galvin and Gagne ©2009
Free Frames
Operating System Concepts – 8th Edition 8.28 Silberschatz, Galvin and Gagne ©2009
Implementation of Page Table
The two memory access problem can be solved by the use of a special
fast-lookup hardware cache called associative memory or translation
look-aside buffers (TLBs)
Operating System Concepts – 8th Edition 8.29 Silberschatz, Galvin and Gagne ©2009
Associative Memory
Operating System Concepts – 8th Edition 8.30 Silberschatz, Galvin and Gagne ©2009
Paging Hardware With TLB
Operating System Concepts – 8th Edition 8.31 Silberschatz, Galvin and Gagne ©2009
TLB Example
TLB size =2 entries, assume
TLB is empty
Page Size = 4 bytes
Logical address space =16 bytes
Physical address space = 64 bytes
Convert the following logical addresses into physical
addresses, and identify if we have a TLB hit or a TLB
miss:
10
14
1
Operating System Concepts – 8th Edition 8.32 Silberschatz, Galvin and Gagne ©2009
Question
Suppose a logical address space is 1KB, and the page-size is 16 bytes.
Suppose TLB has two entries. Both TLB and page table are empty initially.
FIFO is used as TLB replacement algorithm. Suppose the following logical
address is accessed in order: 0x3d,0x30,0xe5,0x7d, 0x33, 0xef. For each of
the following address access:
specify the physical address that is mapped to it.
Suppose it takes 10 ns to access TLB, and 100ns to access memory,
and 8ms to handle page fault. How long time it takes to access this
address?
Operating System Concepts – 8th Edition 8.33 Silberschatz, Galvin and Gagne ©2009
Segmentation
Operating System Concepts – 8th Edition 8.34 Silberschatz, Galvin and Gagne ©2009
User’s View of a Program
Operating System Concepts – 8th Edition 8.35 Silberschatz, Galvin and Gagne ©2009
Logical View of Segmentation
4
1
3 2
4
Operating System Concepts – 8th Edition 8.36 Silberschatz, Galvin and Gagne ©2009
Segmentation Architecture
Logical address consists of a two tuple:
<segment-number, offset>,
Operating System Concepts – 8th Edition 8.37 Silberschatz, Galvin and Gagne ©2009
Example of Segmentation
Operating System Concepts – 8th Edition 8.38 Silberschatz, Galvin and Gagne ©2009
Segmentation Hardware
Operating System Concepts – 8th Edition 8.39 Silberschatz, Galvin and Gagne ©2009
Question
Operating System Concepts – 8th Edition 8.40 Silberschatz, Galvin and Gagne ©2009
Chapter 9: Virtual-Memory
Management
Operating System Concepts Essentials – 9th Edition Silberschatz, Galvin and Gagne ©2013
Background
Code needs to be in memory to execute, but entire program rarely used
Error code, unusual routines, large data structures
Entire program code not needed at same time
Consider ability to execute partially-loaded program
Program no longer constrained by limits of physical memory
Program and programs could be larger than physical memory
Operating System Concepts Essentials – 9th Edition 9.2 Silberschatz, Galvin and Gagne ©2013
Background
Virtual memory – separation of user logical memory from physical memory
Only part of the program needs to be in memory for execution
Logical address space can therefore be much larger than physical address
space
Allows address spaces to be shared by several processes
Allows for more efficient process creation
More programs running concurrently
Less I/O needed to load or swap processes
Operating System Concepts Essentials – 9th Edition 9.3 Silberschatz, Galvin and Gagne ©2013
Question
Operating System Concepts Essentials – 9th Edition 9.4 Silberschatz, Galvin and Gagne ©2013
Virtual Memory That is
Larger Than Physical Memory
Operating System Concepts Essentials – 9th Edition 9.5 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 9th Edition 9.6 Silberschatz, Galvin and Gagne ©2013
Stack and Heap
Operating System Concepts Essentials – 9th Edition 9.7 Silberschatz, Galvin and Gagne ©2013
Virtual-address Space
Operating System Concepts Essentials – 9th Edition 9.8 Silberschatz, Galvin and Gagne ©2013
Shared Library Using Virtual Memory
Operating System Concepts Essentials – 9th Edition 9.9 Silberschatz, Galvin and Gagne ©2013
Demand Paging
Could bring entire process into memory at load time
Or bring a page into memory only when it is needed
Less I/O needed, no unnecessary I/O
Less memory needed
Faster response
More users
Lazy swapper – never swaps a page into memory unless page will be needed
Swapper that deals with pages is a pager
Operating System Concepts Essentials – 9th Edition 9.10 Silberschatz, Galvin and Gagne ©2013
Transfer of a Paged Memory to
Contiguous Disk Space
Operating System Concepts Essentials – 9th Edition 9.11 Silberschatz, Galvin and Gagne ©2013
Valid-Invalid Bit
With each page table entry a valid–invalid bit is associated
(v in-memory – memory resident, i not-in-memory)
Initially valid–invalid bit is set to i on all entries
Example of a page table snapshot:
Frame # valid-invalid bit
v
v
v
v
i
….
i
i
page table
Disk
Main memory
Operating System Concepts Essentials – 9th Edition 9.13 Silberschatz, Galvin and Gagne ©2013
Page Fault
If there is a reference to a page, first reference to that page will trap to operating
system:
page fault
1. Operating system looks at another table to decide:
Invalid reference abort
Just not in memory
2. Get empty frame
3. Swap page into frame via scheduled disk operation
4. Reset tables to indicate page now in memory
Set validation bit = v
5. Restart the instruction that caused the page fault
Operating System Concepts Essentials – 9th Edition 9.14 Silberschatz, Galvin and Gagne ©2013
Aspects of Demand Paging
Extreme case – start process with no pages in memory
OS sets instruction pointer to first instruction of process, non-memory-
resident -> page fault
And for every other process pages on first access
Pure demand paging
Actually, a given instruction could access multiple pages ->
multiple page faults
Pain decreased because of locality of reference
Hardware support needed for demand paging
Page table with valid / invalid bit
Secondary memory (swap device with swap space)
Instruction restart
Operating System Concepts Essentials – 9th Edition 9.15 Silberschatz, Galvin and Gagne ©2013
Instruction Restart
Example
C= A + B
Instructions:
Fetch and decode instruction Add
Fetch A
Fetch B
Add A and B
Store the sum in C
Operating System Concepts Essentials – 9th Edition 9.16 Silberschatz, Galvin and Gagne ©2013
Question
Operating System Concepts Essentials – 9th Edition 9.17 Silberschatz, Galvin and Gagne ©2013
Steps in Handling a Page Fault
Operating System Concepts Essentials – 9th Edition 9.18 Silberschatz, Galvin and Gagne ©2013
Performance of Demand Paging
Stages in Demand Paging
1. Trap to the operating system
2. Save the user registers and process state
3. Determine that the interrupt was a page fault
4. Check that the page reference was legal and determine the location of the page on the disk
5. Issue a read from the disk to a free frame in main memory:
1. Wait in a queue for this device until the read request is serviced
2. Wait for the device seek and/or latency time
3. Begin the transfer of the page to a free frame
6. While waiting, allocate the CPU to some other user
7. Receive an interrupt from the disk I/O subsystem (I/O completed)
8. Save the registers and process state for the other user
9. Determine that the interrupt was from the disk
10. Correct the page table and other tables to show page is now in memory
11. Wait for the CPU to be allocated to this process again
12. Restore the user registers, process state, and new page table, and then resume the interrupted
instruction
Operating System Concepts Essentials – 9th Edition 9.19 Silberschatz, Galvin and Gagne ©2013
Performance of Demand Paging (Cont.)
Operating System Concepts Essentials – 9th Edition 9.21 Silberschatz, Galvin and Gagne ©2013
Question
Consider the page table below (all numbers are in hex) and
assume 1 KB page size. Assume 16-bit logical address and 20-
bit physical address.
What are the page numbers and offsets for the following logical
addresses:
1CC4
0A98
17FC
Provide the physical address for each address
Operating System Concepts Essentials – 9th Edition 9.22 Silberschatz, Galvin and Gagne ©2013
What Happens if There is no Free Frame?
Page replacement – find some page in memory, but not really in use, page it out
Algorithm – terminate? swap out? replace the page?
Performance – want an algorithm which will result in minimum number of
page faults
Operating System Concepts Essentials – 9th Edition 9.23 Silberschatz, Galvin and Gagne ©2013
Page Replacement
Prevent over-allocation of memory by modifying page-fault service routine to
include page replacement
Use modify (dirty) bit to reduce overhead of page transfers – only modified
pages are written to disk
Operating System Concepts Essentials – 9th Edition 9.24 Silberschatz, Galvin and Gagne ©2013
Need For Page Replacement
Operating System Concepts Essentials – 9th Edition 9.25 Silberschatz, Galvin and Gagne ©2013
Basic Page Replacement
3. Bring the desired page into the (newly) free frame; update the page and frame
tables
4. Continue the process by restarting the instruction that caused the trap
Note now potentially 2 page transfers for page fault – increasing EAT
Operating System Concepts Essentials – 9th Edition 9.26 Silberschatz, Galvin and Gagne ©2013
Page Replacement
Operating System Concepts Essentials – 9th Edition 9.27 Silberschatz, Galvin and Gagne ©2013
Page and Frame Replacement Algorithms
Operating System Concepts Essentials – 9th Edition 9.28 Silberschatz, Galvin and Gagne ©2013
First-In-First-Out (FIFO) Algorithm
Reference string: 7,0,1,2,0,3,0,4,2,3,0,3,0,3,2,1,2,0,1,7,0,1
3 frames (3 pages can be in memory at a time per process)
1 7 2 4 0 7
2 0 3 2 1 0 15 page faults
3 1 0 3 2 1
Operating System Concepts Essentials – 9th Edition 9.29 Silberschatz, Galvin and Gagne ©2013
FIFO Page Replacement
Operating System Concepts Essentials – 9th Edition 9.30 Silberschatz, Galvin and Gagne ©2013
First-In-First-Out (FIFO) Algorithm
Can vary by reference string: consider 1,2,3,4,1,2,5,1,2,3,4,5
Adding more frames can cause more page faults!
Belady’s Anomaly
3 frames (9 page faults)
Operating System Concepts Essentials – 9th Edition 9.31 Silberschatz, Galvin and Gagne ©2013
Optimal Algorithm
Replace page that will not be used for longest period of time
9 is optimal for the example on the next slide
Operating System Concepts Essentials – 9th Edition 9.32 Silberschatz, Galvin and Gagne ©2013
Optimal Page Replacement
Operating System Concepts Essentials – 9th Edition 9.33 Silberschatz, Galvin and Gagne ©2013
Least Recently Used (LRU) Algorithm
Move 7 to the
top of stack
Operating System Concepts Essentials – 9th Edition 9.36 Silberschatz, Galvin and Gagne ©2013
Chapter 5: Process
Scheduling
Operating System Concepts – 9th Edition Silberschatz, Galvin and Gagne ©2013
Chapter 5: Process Scheduling
Basic Concepts
Scheduling Criteria
Scheduling Algorithms
Thread Scheduling
Multiple-Processor Scheduling
Real-Time CPU Scheduling
Operating Systems Examples
Operating System Concepts – 9th Edition 6.2 Silberschatz, Galvin and Gagne ©2013
Basic Concepts
Maximum CPU utilization obtained with
multiprogramming
CPU–I/O Burst Cycle – Process execution consists
of a cycle of CPU execution and I/O wait
CPU burst followed by I/O burst
CPU burst distribution is of main concern
Operating System Concepts – 9th Edition 6.3 Silberschatz, Galvin and Gagne ©2013
CPU Scheduler
Short-term scheduler selects from among the processes in ready queue, and allocates the CPU
to one of them
Queue may be ordered in various ways
CPU scheduling decisions may take place when a process:
1. Switches from running to waiting state
2. Switches from running to ready state
3. Switches from waiting to ready
4. Terminates
Scheduling under 1 and 4 is nonpreemptive
Scheduling under 2 and 3 is preemptive
Operating System Concepts – 9th Edition 6.4 Silberschatz, Galvin and Gagne ©2013
Dispatcher
Dispatcher module gives control of the CPU to the process selected by the short-term
scheduler; this involves:
switching context
switching to user mode
jumping to the proper location in the user program to restart that program
Dispatch latency – time it takes for the dispatcher to stop one process and start another
running
Operating System Concepts – 9th Edition 6.5 Silberschatz, Galvin and Gagne ©2013
Scheduling Criteria
CPU utilization – keep the CPU as busy as possible
Throughput – # of processes that complete their execution per time unit
Turnaround time – amount of time to execute a particular process
Waiting time – amount of time a process has been waiting in the ready queue
Response time – amount of time it takes from when a request was submitted until the first
response is produced, not output (for time-sharing environment)
Operating System Concepts – 9th Edition 6.6 Silberschatz, Galvin and Gagne ©2013
Scheduling Algorithm Optimization Criteria
Operating System Concepts – 9th Edition 6.7 Silberschatz, Galvin and Gagne ©2013
Question
Why we need to use scheduling algorithm in the OS, while we
are executing only one process in the CPU?
Operating System Concepts – 9th Edition 6.8 Silberschatz, Galvin and Gagne ©2013
First- Come, First-Served (FCFS) Scheduling
P1 P2 P3
0 24 27 30
Operating System Concepts – 9th Edition 6.9 Silberschatz, Galvin and Gagne ©2013
FCFS Scheduling (Cont.)
Suppose that the processes arrive in the order:
P2 , P3 , P1
The Gantt chart for the schedule is:
P2 P3 P1
0 3 6 30
Waiting time for P1 = 6; P2 = 0; P3 = 3
Average waiting time: (6 + 0 + 3)/3 = 3
Much better than previous case
Convoy effect - short process behind long process
Operating System Concepts – 9th Edition 6.10 Silberschatz, Galvin and Gagne ©2013
Shortest-Job-First (SJF) Scheduling
Associate with each process the length of its next CPU burst
Use these lengths to schedule the process with the shortest time
SJF is optimal – gives minimum average waiting time for a given set of processes
The difficulty is knowing the length of the next CPU request
Operating System Concepts – 9th Edition 6.11 Silberschatz, Galvin and Gagne ©2013
Example of SJF
ProcessArriva l Time Burst Time
P1 0.0 6
P2 2.0 8
P3 4.0 7
P4 5.0 3
P4 P1 P3 P2
0 3 9 16 24
Operating System Concepts – 9th Edition 6.12 Silberschatz, Galvin and Gagne ©2013
Priority Scheduling
A priority number (integer) is associated with each process
The CPU is allocated to the process with the highest priority (smallest integer highest priority)
Preemptive
Nonpreemptive
SJF is priority scheduling where priority is the inverse of predicted next CPU burst time
Operating System Concepts – 9th Edition 6.13 Silberschatz, Galvin and Gagne ©2013
Example of Priority Scheduling
ProcessA arri Burst TimeT Priority
P1 10 3
P2 1 1
P3 2 4
P4 1 5
P5 5 2
P1 P2 P1 P3 P4
0 1 6 16 18 19
Operating System Concepts – 9th Edition 6.14 Silberschatz, Galvin and Gagne ©2013
Round Robin (RR)
Each process gets a small unit of CPU time (time quantum q), usually 10-100 milliseconds. After
this time has elapsed, the process is preempted and added to the end of the ready queue.
If there are n processes in the ready queue and the time quantum is q, then each process gets 1/n
of the CPU time in chunks of at most q time units at once. No process waits more than (n-1)q time
units.
Timer interrupts every quantum to schedule next process
Performance
q large FIFO
q small q must be large with respect to context switch, otherwise overhead is too high
Operating System Concepts – 9th Edition 6.15 Silberschatz, Galvin and Gagne ©2013
Example of RR with Time Quantum = 4
Process Burst Time
P1 24
P2 3
P3 3
The Gantt chart is:
P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30
Operating System Concepts – 9th Edition 6.16 Silberschatz, Galvin and Gagne ©2013
Time Quantum and Context Switch Time
Operating System Concepts – 9th Edition 6.17 Silberschatz, Galvin and Gagne ©2013
Turnaround Time Varies With
The Time Quantum
Operating System Concepts – 9th Edition 6.18 Silberschatz, Galvin and Gagne ©2013
Question
What is the best value for the quantum time; very large or very
small?
Operating System Concepts – 9th Edition 6.19 Silberschatz, Galvin and Gagne ©2013
Thread Scheduling
Many-to-one and many-to-many models, thread library schedules user-level threads to run on Lightweight
processes (LWP)
Known as process-contention scope (PCS) since scheduling competition is within the process
Typically done via priority set by programmer
Kernel thread scheduled onto available CPU is system-contention scope (SCS) – competition among all
threads in system
Operating System Concepts – 9th Edition 6.20 Silberschatz, Galvin and Gagne ©2013
Chapter 3: Processes
Operating System Concepts – 9th Edition Silberschatz, Galvin and Gagne ©2013
Chapter 3: Processes
Process Concept
Process Scheduling
Operations on Processes
Interprocess Communication
Operating System Concepts – 9th Edition 3.2 Silberschatz, Galvin and Gagne ©2013
Process Concept
Operating System Concepts – 9th Edition 3.3 Silberschatz, Galvin and Gagne ©2013
Process Concept (Cont.)
Program is passive entity stored on disk (executable file),
process is active
Program becomes process when executable file loaded into
memory
One program can be several processes
Consider multiple users executing the same program
Operating System Concepts – 9th Edition 3.4 Silberschatz, Galvin and Gagne ©2013
Process in Memory
Operating System Concepts – 9th Edition 3.5 Silberschatz, Galvin and Gagne ©2013
Process State
As a process executes, it changes state
new: The process is being created
running: Instructions are being executed
waiting: The process is waiting for some event to occur
ready: The process is waiting to be assigned to a processor
terminated: The process has finished execution
Operating System Concepts – 9th Edition 3.6 Silberschatz, Galvin and Gagne ©2013
Process Control Block (PCB)
Information associated with each process
(also called task control block)
Process state – running, waiting, etc
Program counter – location of
instruction to next execute
CPU registers – contents of all process-
centric registers
CPU scheduling information- priorities,
scheduling queue pointers
Memory-management information –
memory allocated to the process
Accounting information – CPU used,
clock time elapsed since start, time
limits
I/O status information – I/O devices
allocated to process, list of open files
Operating System Concepts – 9th Edition 3.7 Silberschatz, Galvin and Gagne ©2013
CPU Switch From Process to Process
Operating System Concepts – 9th Edition 3.8 Silberschatz, Galvin and Gagne ©2013
Question
Operating System Concepts – 9th Edition 3.9 Silberschatz, Galvin and Gagne ©2013
Process Scheduling
Operating System Concepts – 9th Edition 3.10 Silberschatz, Galvin and Gagne ©2013
Ready Queue And Various I/O Device Queues
Operating System Concepts – 9th Edition 3.11 Silberschatz, Galvin and Gagne ©2013
Representation of Process Scheduling
Operating System Concepts – 9th Edition 3.12 Silberschatz, Galvin and Gagne ©2013
Schedulers
Short-term scheduler (or CPU scheduler) – selects which process should
be executed next and allocates CPU
Sometimes the only scheduler in a system
Short-term scheduler is invoked frequently (milliseconds) (must be
fast)
Long-term scheduler (or job scheduler) – selects which processes should
be brought into the ready queue
Long-term scheduler is invoked infrequently (seconds, minutes)
(may be slow)
The long-term scheduler controls the degree of multiprogramming
Processes can be described as either:
I/O-bound process – spends more time doing I/O than computations,
many short CPU bursts
CPU-bound process – spends more time doing computations; few very
long CPU bursts
Long-term scheduler strives for good process mix
Operating System Concepts – 9th Edition 3.13 Silberschatz, Galvin and Gagne ©2013
Addition of Medium Term Scheduling
Medium-term scheduler can be added if degree of multiple
programming needs to decrease
Remove process from memory, store on disk, bring back in
from disk to continue execution: swapping
Operating System Concepts – 9th Edition 3.14 Silberschatz, Galvin and Gagne ©2013
Context Switch
When CPU switches to another process, the system must save
the state of the old process and load the saved state for the
new process via a context switch
Context of a process represented in the PCB
Context-switch time is overhead; the system does no useful
work while switching
The more complex the OS and the PCB the longer the
context switch
Time dependent on hardware support
Some hardware provides multiple sets of registers per CPU
multiple contexts loaded at once
Operating System Concepts – 9th Edition 3.15 Silberschatz, Galvin and Gagne ©2013
Operations on Processes
Operating System Concepts – 9th Edition 3.16 Silberschatz, Galvin and Gagne ©2013
Process Creation & Exec.
Parent process create children processes, which, in turn create
other processes, forming a tree of processes
Generally, process identified and managed via a process
identifier (pid)
Resource sharing options
Parent and children share all resources
Children share subset of parent’s resources
Parent and child share no resources
Execution options
Parent and children execute concurrently
Parent waits until children terminate
Address space
Child duplicate of parent
Child has a program loaded into it
Operating System Concepts – 9th Edition 3.17 Silberschatz, Galvin and Gagne ©2013
Process Creation & exec. (Cont.)
UNIX examples
fork() creates new process
exec() used after a fork() to execute the process code.
Operating System Concepts – 9th Edition 3.18 Silberschatz, Galvin and Gagne ©2013
C Programming intro
https://www.onlinegdb.com/fork/r1rLnO-kb
Operating System Concepts – 9th Edition 3.19 Silberschatz, Galvin and Gagne ©2013
Hello World
#include<stdio.h>
int main()
{
printf("Hello, World!");
return0;
}
Operating System Concepts – 9th Edition 3.20 Silberschatz, Galvin and Gagne ©2013
C Program Forking Separate Process
int main()
{
pid_t pid;
/* fork another process */
pid = fork();
if (pid < 0) { /* error occurred */
fprintf(stderr, "Fork Failed");
exit(-1);
}
else if (pid == 0) { /* child process */
execlp("/bin/ls", "ls", NULL);
}
else { /* parent process */
/* parent will wait for the child to complete */
wait (NULL);
printf ("Child Complete");
exit(0);
}
}
Operating System Concepts – 9th Edition 3.21 Silberschatz, Galvin and Gagne ©2013
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main()
{
printf( "The process identifier (pid) of the parent process is %d\n", (int)getpid() );
/* fork another process */
int pid = fork();
if ( pid == 0 ) {
printf( "After the fork, the process identifier (pid) " "of the child is %d\n", (int)getpid() );
} else {
printf( "After the fork, the process identifier (pid) " "of the parent is still %d\n - fork()
returned %d\n", (int)getpid(), pid );
}
return 0;
}
Operating System Concepts – 9th Edition 3.22 Silberschatz, Galvin and Gagne ©2013
A tree of processes on a typical Solaris
Operating System Concepts – 9th Edition 3.23 Silberschatz, Galvin and Gagne ©2013
Question
Operating System Concepts – 9th Edition 3.24 Silberschatz, Galvin and Gagne ©2013
Process Termination
Operating System Concepts – 9th Edition 3.25 Silberschatz, Galvin and Gagne ©2013
Process Termination
Operating System Concepts – 9th Edition 3.26 Silberschatz, Galvin and Gagne ©2013
How processes communicate?
Operating System Concepts – 9th Edition 3.27 Silberschatz, Galvin and Gagne ©2013
Interprocess Communication
Processes within a system may be independent or cooperating.
Independent process cannot affect or be affected by the execution
of another process
Cooperating process can affect or be affected by other processes,
including sharing data
Reasons for cooperating processes:
Information sharing
Computation speedup
Modularity
Convenience
Cooperating processes need interprocess communication (IPC)
Two models of IPC
Shared memory
Message passing
Operating System Concepts – 9th Edition 3.28 Silberschatz, Galvin and Gagne ©2013
Communications Models
Operating System Concepts – 9th Edition 3.29 Silberschatz, Galvin and Gagne ©2013
Question
Operating System Concepts – 9th Edition 3.30 Silberschatz, Galvin and Gagne ©2013
Interprocess Communication – Shared Memory
receive(message)
If processes P and Q wish to communicate, they need to:
Establish a communication link between them
Exchange messages via send/receive
Operating System Concepts – 9th Edition 3.31 Silberschatz, Galvin and Gagne ©2013
Interprocess Communication – Message Passing
Operating System Concepts – 9th Edition 3.32 Silberschatz, Galvin and Gagne ©2013