Proccess Management Flashcards
Define a program
A program is a set of instructions for performing a specific task (passive), and is stored on disk.
when you run it, it is a program associated with a process
What is a process
A process is a program in execution (active), and requires CPU resources, primary memory, and I/O.
By organising a computer system into processes we achieve what
both modularity (we can switch between them) and improved performance (allowing us to improve performance).
What happens in the NEW state of a process lifecycle?
The process is created and enters the system. It awaits admission to the READY state.
What happens in the READY state?
The process is prepared to run and waits to be dispatched to the CPU.
What happens in the RUNNING state?
The process is actively executing on the CPU.
When does a process move to the WAITING state?
A process moves to the WAITING state when it begins I/O operations and waits for I/O to complete.
When does a process enter the TERMINATED state?
The process enters the TERMINATED state when it finishes execution and exits.
What is the transition from READY to RUNNING called?
The transition is called dispatch, where the CPU scheduler selects a process to run.
What happens when a process is paused during execution?
The process transitions from RUNNING back to READY if it’s preempted (e.g., by a higher-priority process).
What happens when a process starts an I/O operation?
The process moves from RUNNING to WAITING.
What happens when a process completes its I/O operation?
The process transitions from WAITING to READY.
What determines the transfer between READY and RUNNING states?
The transfer depends on processor scheduling, which prioritises processes based on their assigned priority.
What is a process control block
A Process Control Block (PCB) is a data structure maintained by the operating system to store information about a process. It is used to manage processes during execution.
What are the components of the process control block
- Process number
- Process state
- process address space
- process I/O
Where is the process control block stored
in the memory or on the disk
How to stop running process A and start process B:
- change the process scheduling state of process A
- save the context of process A
- load the context of process B
- change the process scheduling state of process B
What is a context switch
when the CPU switches from running one process to another.
What is the tradeoff of context switches
Too few switches lead to poor responsiveness (as it is never actually running the task rather just moving data), while too many switches increase overhead, reducing efficiency.
What 4 sections does a process address space have
- a stack for temporary data
- a heap for dynamically-allocated data
- a data for static data
- a text for program code
How does a stack work
When a function is called, temporary variables are added to the top of the stack. When exiting a function, these variables are removed from the top of the stack.
How does a heap work
In the heap, blocks of memory are allocated and removed in an arbitrary order. The heap is used for variables that need to persist beyond the scope of a single function or need a flexible amount of memory.
What is the issue with stack and heap in address space
The stack grows downwards while the heap grows upwards thus they could collide so its up to the OS to stop this by providing more address space
What is process calling
A process is created at the request of a different process. In Linux there are four system calls for process spawning.