Process Management in OS Flashcards
Process
A program in execution: A process is essentially a program in the midst of execution. Processes are the active content within a computer system, starting from when the program is opened (or executed) until it is closed.
Batch System
Processes are referred to as “jobs.” This terminology is reminiscent of older computing systems where tasks were submitted in batches.
Time-shared systems
Processes are often referred to as “user programs” or “tasks.” This reflects the multi-user, multitasking nature of such systems where multiple processes may be executed concurrently.
Items of a process
- Program counter: Holds the address of the next instruction to be executed, thus guiding the sequential flow of control.
- Stack: Used for storing temporary data like function parameters, return addresses, and local variables.
- Data section: Contains the global and static variables used by the program.
Process State
- New: The process is being created.
- Running: The process is currently executing instructions.
- Waiting: The process is paused, waiting for an event to occur.
- Ready: The process is ready to run and waiting for processor allocation.
- Terminated: The process has completed execution and is exiting.
Process Control Block
- Process State: The current status of the process (e.g., New, Running, Waiting, Ready, Terminated).
- Program Counter: Holds the address of the next instruction for the process to execute.
- CPU Registers: Contains the process’s current register values when it is not running.
- CPU Scheduling Information: Includes priority information and other data necessary for scheduling the process.
- Memory-Management Information: Details about the process’s allocated memory, including base and limit registers.
- Accounting Information: Information tracking the use of processor time and other resources by the process.
- I/O Status Information: Lists the I/O devices allocated to the process and a list of open files.
Process Scheduling Queues
- Job Queue: The set of all processes in the system.
- Ready Queue: The set of all processes residing in main memory that are ready and waiting to execute.
- Device Queues: Sets of processes waiting for an I/O device.
Short-term scheduler
- Selects which process to execute next and allocates CPU.
- Invoked very frequently to maintain efficient processor use.
Long-term scheduler
- Selects processes to bring into the ready queue.
- Controls the degree of multiprogramming.
- Balances the mix of CPU-bound and I/O-bound processes.
Process Creation
- Parent Process Creates Children: Parent processes can create child processes, forming a tree of processes.
- Resource Sharing: Determines how resources are shared between parent and child processes.
- Execution: Parent and children can either execute concurrently or the parent can wait for the children to terminate.
- Address Space:
The child process starts as a duplicate of the parent (same program and data). The child can load a new program into its address space. - UNIX System Calls: fork to create a new process, exec to load a new program into the process’s address space.
Process termination - exit
- The process completes its execution and asks the OS to delete it.
- The parent process can receive output data from the child through the wait system call.
- The operating system deallocates the resources of the process.
Process Termination - abort
- The child has exceeded its allocated resources.
- The task assigned to the child is no longer required.
- The parent is exiting, and the OS does not allow the child to continue independently.
Advantages of Process Cooperation
- Information sharing
- Computation speed-up
- Modularity
- Convenience
Direct Communicaton
- Links are established automatically.
- A link is associated with exactly one pair of processes.
- Between each pair, there exists exactly one link.
- Links are usually bi-directional, though they can be unidirectional.
Indirect Communication
- A link is established only if processes share a common mailbox.
- A link can be associated with many processes.
- Each pair of processes can share several links.
- Links can be unidirectional or bi-directional.