07 CSC520 03 Bahan Pengajaran Chapter 03 Process
Chapter 3: Processes
Overview
Title: Processes Operating System Concepts
Authors: Silberschatz, Galvin and Gagne
Edition: 9th Edition
Year: 2013
Major Topics Covered
Process Concept
Process Scheduling
Operations on Processes
Interprocess Communication (IPC)
Examples of IPC Systems
Communication in Client-Server Systems
Key Objectives
Introduce the notion of a process: A program in execution forming the basis of computation.
Describe features of processes:
Scheduling
Creation and termination
Communication
Explore IPC using:
Shared memory
Message passing
Describe communication in client-server systems.
Process Concept
Definition: A process is a program in execution, including:
Program code (text section)
Current activities (program counter, processor registers)
Stack (temporary data)
Data section (global variables)
Heap (dynamically allocated memory)
Difference Between Program and Process:
Program: Passive entity stored on disk.
Process: Active entity loaded into memory.
A single program can have multiple processes, allowing multiple users to execute the same program.
Process State
Processes change state as execution progresses:
new: The process is being created
running: Instructions are being executed
waiting: Waiting for an event to occur
ready: Waiting to be assigned to a processor
terminated: The process has finished execution
Process Control Block (PCB)
Contains information associated with each process, including:
Process state
Program counter
CPU registers
CPU scheduling information
Memory-management information
Accounting information
I/O status information
Process Scheduling
Goal: Maximize CPU usage and minimize switching time.
Schedulers:
Short-term scheduler: Selects which process to execute next (frequently invoked).
Long-term scheduler: Brings processes into the ready queue (invoked less frequently).
Medium-term scheduler: Manages swapping processes between memory and disk.
Types of processes:
I/O-bound: More time on I/O than computation.
CPU-bound: More time on computation than I/O.
Process Creation and Termination
Creation: Parent processes create child processes, forming a tree with a process identifier (pid).
Termination: Executed by calling exit() and returning status to the parent with wait().
Cascading termination: If a parent process is terminated, its children are also terminated.
Interprocess Communication (IPC)
Types of Processes:
Independent Process: Cannot affect others.
Cooperating Process: Can be affected and share data.
Reasons for IPC: Information sharing, speedup computation, modularity, convenience.
IPC Models: Shared Memory and Message Passing.
Example IPC Systems
POSIX: Uses shared memory, enabling processes to read/write data.
Mach: Message-based communication with mailboxes.
Windows: Local Procedure Call (LPC) for message passing between processes.
Communication in Client-Server Systems
Sockets: defined by IP address and port.
Remote Procedure Calls (RPC): Abstracts inter-process communication over a network.
Pipes: Conduit allowing communication; can be ordinary (parent-child only) or named (bidirectional).
Synchronization and Buffering
Message Passing: Can be blocking (synchronous) or non-blocking (asynchronous).
Buffering Types:
Zero Capacity: Sender waits for receiver.
Bounded Capacity: Finite messages; sender waits if full.
Unbounded Capacity: Infinite messages.