Process Model:
A process model is a conceptual framework used to understand and manage the execution of processes within an operating system.
• It describes the different states a process can be in, the transitions between these states, and the various activities associated with each state.
Process Creation:
Process creation is the mechanism by which new processes are generated within an operating system.
• This can occur through various methods, such as user requests, system initialization, or by another process.
Steps in Process Creation:
- Request: A request is made to create a new process (e.g., a user command or system call).
- Process Control Block (PCB) Allocation: A new PCB is allocated for the new process.
- Memory Allocation: Memory space is allocated for the process’s code, data, and stack.
- Initialization: The process’s PCB is initialized, including setting up the program counter, registers, and priority.
- Linking to Parent: If the new process is created by another process, a parent-child relationship is established.
- State Transition: The new process is placed in the ready state, awaiting CPU allocation.
Example:
In UNIX-like systems, processes are created using the fork() system call, which duplicates the calling process. The new process (child) gets a copy of the parent’s address space and resources. The exec() system call can then be used to replace the child’s address space with a new program.
Process Control Block (PCB):
The Process Control Block is a data structure used by the operating system to store information about a process. It is essential for process management and context switching.
Components of PCB:
- Process ID (PID): Unique identifier for the process.
- Process State: Current state of the process (e.g., ready, running).
- Program Counter: Address of the next instruction to execute.
- CPU Registers: Values of the CPU registers for the process.
- Memory Management Information: Includes base and limit registers, page tables, etc.
- I/O Status Information: List of I/O devices allocated to the process, open files, etc.
- Accounting Information: Includes CPU usage, process start time, and other statistical data.
- Parent Process ID: Identifier of the parent process, if any.
- Priority: Priority level of the process.
- Pointer to Next PCB: Used to link PCBs in scheduling queues.