Definition:
- A process is the fundamental unit of work in an operating system.
- Process management includes creating and deleting processes and providing mechanisms for processes to communicate and synchronize with each other.
- has pid (process identifier)
- Executable program becomes process when it is loaded into memory
- Types of processes:
- System process
- User process
- Foreground process
- Background process
- Independent vs cooperating process:
- Independent process: not affected by and doesnt affect others (no shared data)
- Cooperating process: affected by other (shared data)
Process State
- Ready: waiting to be assigned to CPU
- Running: in CPU
Process Control Block (PCB)
- Found in memory
- PCB manages information associated with each process:
- Process state: running, waiting, etc.
- Program counter: location of instruction to next execute
- CPU registers: contents of all process-centric registers
- CPU scheduling: priorities, scheduling queue pointers
- Memory-management information – memory allocated
- Accounting information: CPU used, time elapsed since start
- I/O information: I/O devices allocated, list of open files
- …
Process scheduling:
- Ready queue: processes residing in main memory waiting to execute
- Wait queue: processes waiting for an event (ie I/O)
- A context switch occurs when the CPU switches from one process to another.
- Pure overhead
- Hardware-dependent
Process creation:
- OSs provide a create-process function to create a new process
- Parent process is the one called the create-process function (folk())
- Child process is created after the create-process function is called
- Execution options:
- Parent and children execute concurrently
- Parent waits until children terminate
- Parent process links to many child process below like a tree
- If parent process is terminated, all children are also killed
Process termination:
- If it executes last statement and call
exit()
to notify OS to delete it
- Its parent calls abort() or kill()
- Exceed allocated resources
- Task assigned is no longer required
- The parent is terminated