Lecture 03 Flashcards
(37 cards)
What are the four possible status codes for a process?
O, S, R, and Z
What does the process status code ‘O’ mean?
The process is running on a processor.
What does the process status code ‘S’ mean?
The process is sleeping.
It is waiting for an event complete.
What does the process status code ‘R’ mean?
Runnable.
The process is on run queue.
What does the process status code ‘Z’ mean?
The process is in Zombie State.
It has terminated and the parent is not waiting.
What is a process?
A program in execution.
What function is used to get a processes id?
getpid()
What function is used to create a new process?
fork()
Parent and child processes execute:
A - In Parallel
B - In Series
In parallel.
What is the return value of fork for the parent process?
The new child’s process id.
What is the return value of fork for the child process?
0
What function is used to get the process id of a process’ parent?
getppid
What happens if a parent terminates before its child process?
The child is assigned the ‘init’ process as its parent.
What process id does the ‘init’ process have?
1.
What happens to the memory space of a process (in theory), after a fork?
Its entire memory space is copied to the new process so that they both have an independent copy.
What function is used to wait on a child process completing?
wait()
What does the wait() function do?
Blocks until a child terminates.
When will wait return immediately?
When there are no children or a child has already terminated.
What happens when a child process terminates but has not been waited on by the parent?
It becomes a zombie state.
When a process enters zombie state, what happens to its memory and resources?
They are de-allocated.
What does it mean for a Zombie process to be ‘reaped’?
Its parent process has waited on it, so it is now cleared from the ‘process table’.
What does the ‘exec’ function do?
Replaces the current program of a process with a new program.
What function replaces the current program of a process with a new program?
exec()
Using exec to open a new program, what happens to the text, stack, heap, and data of the current process?
They are overwritten.