Unit- III Process Management
Process
management is one of the core functions of an operating system. It's about how
the OS handles the creation, scheduling, and termination of processes. Let's
delve into the details.
1. Definition of a Process:
A process can be thought of as a program in execution. It includes the current
values of the program counter, registers, and variables, as well as the code
itself. Each process is typically executed in its own process address space.
2. Process Life Cycle: The
state of a process changes as it moves through various stages:
- New: The process is being created.
- Ready: The process is ready to be assigned
to a processor and run.
- Running: The process is currently being
executed.
- Waiting: The process is waiting for an event
or resource.
- Terminated: The process has finished
execution.
3. Process Control Block (PCB):
For every process, the OS maintains a data structure known as the Process Control
Block. It contains information about the process such as:
- Process ID
- Process State (new, ready, etc.)
- Program Counter
- CPU Registers
- CPU Scheduling Information
- Memory Management Information
- List of I/O devices allocated to the process
4. Process Scheduling: The
OS decides which of the ready processes should be moved to the running state.
Several algorithms can be employed for this:
- First-Come-First-Serve (FCFS)
- Shortest Job Next (SJN)
- Priority Scheduling
- Round Robin (RR)
- Multilevel Queue Scheduling
5. Context Switching: When
the CPU switches from one process to another, it saves the state of the old
process and loads the saved state for the new process. This operation is called
a context switch.
6. Process Creation & Termination:
- Processes can be created by other processes using
system calls. A parent process can create child processes.
- Processes are terminated when they've finished
execution or when they are killed either by their own actions or by
others.
7. Inter-process Communication
(IPC): Processes often need to communicate with each other. This can be
done using various mechanisms like:
- Message Passing: Processes communicate with
each other without sharing variables.
- Shared Memory: A common memory location is
shared by multiple processes for communication.
8. Process Synchronization:
When processes communicate, they often need to be synchronized to avoid
conflicts and ensure data integrity. Mechanisms include:
- Semaphores: A high-level synchronization
primitive.
- Locks: Prevent more than one process from
accessing a critical section.
- Monitors: A synchronization tool that wraps
up the shared variable/condition and the methods to access them in one
package.
9. Deadlock Management:
Deadlocks occur when processes are waiting for resources that are held by other
processes. They are in a state where they can't move forward. The OS must:
- Prevent: Implement a strategy to ensure
deadlocks never occur.
- Avoid: Allow conditions that might cause a
deadlock but ensure they don't occur in practice.
- Detect: Allow deadlocks to occur but have a
mechanism to detect them.
- Recover: After detection, recover the system
from the deadlock.
Conclusion: Process
management is an essential aspect of an OS, ensuring efficient utilization of
the CPU, providing multitasking capabilities, and allowing processes to work
harmoniously without conflicts. The effectiveness of process management
directly impacts the system's performance and user experience.
password please
ReplyDelete