3-Process Concept
3-Process Concept
Outline
3.1 Introduction
3.1.1 Definition of Process
3.2 Process States: Life Cycle of a Process
3.3 Process Management
3.3.1 Process States and State Transitions
3.3.2 Process Control Blocks (PCBs)/Process Descriptors
3.3.3 Process Operations
3.3.4 Suspend and Resume
3.3.5 Context Switching
3.4 Interrupts
3.4.1 Interrupt Processing
3.4.2 Interrupt Classes
3.5 Interprocess Communication
3.5.1 Signals
3.5.2 Message Passing
3.6 Case Study: UNIX Processes
3.1 Introduction
A program in execution
A process has its own address space consisting of:
Text region
Stores the code that the processor executes
Data region
Stores variables and dynamically allocated memory
Stack region
Stores instructions and local variables for active procedure
calls
3.2 Process States: Life
Cycle of a Process
A process moves through a series of discrete
process states:
Running state
The process is executing on a processor
Ready state
The process could execute on a processor if one were
available
Blocked state
The process is waiting for some event to happen before
it can proceed
The OS maintains a ready list and a blocked list to
store references to processes not running
3.3 Process Management
Process table
The OS maintains pointers to each process’s PCB in a
system-wide or per-user process table
Allows for quick access to PCBs
When a process is terminated, the OS removes the
process from the process table and frees all of the
process’s resources
3.3.2 Process Control Blocks
(PCBs)/Process Descriptors
3.3.3 Process Operations
Context switches
Performed by the OS to stop executing a running
process and begin executing a previously ready
process
Save the execution context of the running process to
its PCB
Load the ready process’s execution context from its
PCB
Must be transparent to processes
Require the processor to not perform any “useful”
computation
OS must therefore minimize context-switching time
Performed in hardware by some architectures
3.3.5 Context Switching
3.4 Interrupts
Handling interrupts
After receiving an interrupt, the processor completes
execution of the current instruction, then pauses the
current process
The processor will then execute one of the kernel’s
interrupt-handling functions
The interrupt handler determines how the system
should respond
Interrupt handlers are stored in an array of pointers
called the interrupt vector
After the interrupt handler completes, the
interrupted process is restored and executed or the
next process is executed
3.4.1 Interrupt Processing
3.4.2 Interrupt Classes
Supported interrupts depend on a system’s architecture
The IA-32 specification distinguishes between two types of signals a
processor may receive:
Interrupts
Notify the processor that an event has occurred or that an external device’s status
has changed
Generated by devices external to a processor
Exceptions
Indicate that an error has occurred, either in hardware or as a result of a software
instruction
Classified as faults, traps or aborts
3.4.2 Interrupt Classes
Figure 3.8 Common interrupt types recognized in the Intel IA-32 architecture.
3.4.2 Interrupt Classes
Figure 3.9 Intel IA-32 exception classes.
3.5.1 Signals
Software interrupts that notify a process that an event has occurred
Do not allow processes to specify data to exchange with other processes
Processes may catch, ignore or mask a signal
Catching a signal involves specifying a routine that the OS calls when it
delivers the signal
Ignoring a signal relies on the operating system’s default action to handle the
signal
Masking a signal instructs the OS to not deliver signals of that type until the
process clears the signal mask
3.5.2 Message Passing
Message-based interprocess communication
Messages can be passed in one direction at a time
One process is the sender and the other is the receiver
Message passing can be bidirectional
Each process can act as either a sender or a receiver
Messages can be blocking or nonblocking
Blocking requires the receiver to notify the sender when the message is
received
Nonblocking enables the sender to continue with other processing
Popular implementation is a pipe
A region of memory protected by the OS that serves as a buffer, allowing two
or more processes to exchange data
3.5.2 Message Passing
IPC in distributed systems
Transmitted messages can be flawed or lost
Acknowledgement protocols confirm that transmissions have been properly
received
Timeout mechanisms retransmit messages if acknowledgements are not
received
Ambiguously named processes lead to incorrect message referencing
Messages are passed between computers using numbered ports on which
processes listen, avoiding this problem
Security is a significant problem
Ensuring authentication