Week3 ITE240 Process Management
Week3 ITE240 Process Management
Operating System Concepts – 9th Edition 3.2 Silberschatz, Galvin and Gagne
Objectives
To introduce the notion of a process -- a program
in execution, which forms the basis of all
computation
To describe the various features of processes,
including scheduling, creation and termination,
and communication
To explore interprocess communication using
shared memory and message passing
Operating System Concepts – 9th Edition 3.3 Silberschatz, Galvin and Gagne
Multitasking in Mobile Systems
Some mobile systems (e.g., early version of iOS)
allow only one process to run, others suspended
Due to screen real estate, user interface limits iOS
provides for a
Single foreground process- controlled via user
interface
Multiple background processes– in memory,
running, but not on the display, and with limits
Limits include single, short task, receiving
notification of events, specific long-running tasks
like audio playback
Android runs foreground and background, with fewer
limits
Background process uses a service to perform
tasks
Service can keep running even if background
process is suspended
Service has no user interface,
Operating System Concepts – 9th Edition 3.4
small memory useGalvin and Gagne
Silberschatz,
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.5 Silberschatz, Galvin and Gagne
Operations on Processes
Operating System Concepts – 9th Edition 3.6 Silberschatz, Galvin and Gagne
Process Creation
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
Operating System Concepts – 9th Edition 3.7 Silberschatz, Galvin and Gagne
A Tree of Processes
Operating System Concepts – 9th Edition 3.8 Silberschatz, Galvin and Gagne
Process Creation (Cont.)
Address space
Child duplicate of parent
Child has a program loaded into it
UNIX examples
fork() system call creates new process
exec() system call used after a fork() to replace
the process’ memory space with a new program
Operating System Concepts – 9th Edition 3.9 Silberschatz, Galvin and Gagne
C Program Forking Separate Process
Operating System Concepts – 9th Edition 3.10 Silberschatz, Galvin and Gagne
Process Termination
Operating System Concepts – 9th Edition 3.11 Silberschatz, Galvin and Gagne
Process Termination
Operating System Concepts – 9th Edition 3.12 Silberschatz, Galvin and Gagne
Multiprocess Architecture – Chrome Browser
Operating System Concepts – 9th Edition 3.13 Silberschatz, Galvin and Gagne
Interprocess Communication
Processes within a system may be independent or
cooperating
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.14 Silberschatz, Galvin and Gagne
Communications Models
(a) Message passing. (b) shared memory.
Operating System Concepts – 9th Edition 3.15 Silberschatz, Galvin and Gagne
Cooperating Processes
Independent process cannot affect or be affected by
the execution of another process
Cooperating process can affect or be affected by the
execution of another process
Advantages of process cooperation
Information sharing
Computation speed-up
Modularity
Convenience
Operating System Concepts – 9th Edition 3.16 Silberschatz, Galvin and Gagne
Producer-Consumer Problem
Paradigm for cooperating processes, producer
process produces information that is consumed
by a consumer process
unbounded-buffer places no practical limit on
the size of the buffer
bounded-buffer assumes that there is a fixed
buffer size
Operating System Concepts – 9th Edition 3.17 Silberschatz, Galvin and Gagne