Process
threads within the Process will share the memory space.
Different processes will have different memory space.
Overview
The term process
in the context of operating systems refers to a fundamental concept that encapsulates the execution of a program. It includes the program's code, its current activity, and its execution state. Understanding processes is crucial for grasping how operating systems manage and execute tasks.
Key Characteristics
-
Program vs. Process:
- Program: A static collection of instructions stored in a file.
- Process: A dynamic instance of a program in execution, including the program counter, CPU registers, and memory.
-
Process State:
- New: The process is being created.
- Running: Instructions are being executed.
- Waiting: The process is waiting for an event (e.g., I/O completion).
- Ready: The process is waiting to be assigned to a processor.
- Terminated: The process has finished execution.
-
Process Control Block (PCB):
- A data structure used by the operating system to store all the information about a process. It includes the process state, program counter, CPU registers, memory limits, and accounting information.
Process Management
-
Process Creation:
- Processes are created by the OS through system calls such as
fork()
in Unix/Linux orCreateProcess()
in Windows.
- Processes are created by the OS through system calls such as
-
Process Scheduling:
- The OS uses scheduling algorithms (e.g., Round Robin, Priority Scheduling) to allocate CPU time to processes, ensuring efficient CPU utilization and fair distribution of resources.
-
Inter-Process Communication (IPC):
- Mechanisms that allow processes to communicate and synchronize their actions. Common IPC methods include pipes, message queues, semaphores, and shared memory.
-
Process Termination:
- Processes terminate when they complete their execution or are terminated by the OS. The termination status is often communicated back to the parent process.
Process Synchronization
-
Race Conditions:
- Occur when multiple processes attempt to modify shared data concurrently, leading to unpredictable outcomes.
-
Critical Sections:
- Sections of code that access shared resources and must be executed by only one process at a time.
-
Synchronization Mechanisms:
- Mutexes, Semaphores, Monitors, and Condition Variables are used to enforce mutual exclusion and ensure orderly access to shared resources.
Practical Considerations
-
Concurrency vs. Parallelism:
- Concurrency: Multiple processes or threads make progress, but not necessarily simultaneously.
- Parallelism: Multiple processes or threads execute simultaneously on multiple cores or processors.
-
Deadlock:
- A condition where a set of processes are blocked forever, waiting for resources held by each other. Strategies like Deadlock Detection, Prevention, and Avoidance are used to handle deadlocks.
Backlinks