Processes Flashcards
Process
Program in Execution. It is the basic unit of execution in an OS.
What must a process have to run?
Memory to contain the program code and data, and a set of CPU registers to support execution.
Process Control Block
Contains the information needed for a process to run. It is a data structure that defines the process to the OS. Processes are represented as PCBs to the OS.
What does a process state consist of?
Code, PC, stack, stack pointer, static data, heap, PID, values of registers, and process execution state.
Process Execution State
Can be new, ready, running, blocked, or terminated
What happens with the PCB when a process is created?
OS allocates and initializes a new PCB and places the PCB on the state queue. When a process terminates, the PCB is deallocated.
What happens when a process is created?
(1) the loader reads and interprets the executable file, (2) it sets up the process’s memory, (3) argv and argc are pushed onto the stack, (4) the loader sets the CPU registers and calls start()
How is fork() different in the child and parent?
What fork() returns. 0 in the child and the child’s PID in the parent.
What happens to the stack and heap in exec?
Overwritten!
Is the result of exec a same process and program?
No! Same process but different program.
exit()
deallocates all files and memory. If the process has a parent, it becomes a zombie
wait()
waits for the parents children. If there is a zombie process, wait returns immediately and deallocates the zombie.
Zombie State
The child is not terminated and instead holds the return value and waits for the parent to reap it.
Signals
Are vitrual interrupts. They are kernal-defined and have the signal stack and signal masking in user space
Besides signals, what are other forms of inter-process communication?
Pipes, messages, and shared memory