Ch. 2 - Processes Flashcards
fork()
Creates an identical copy of the calling process with the same data, values, and registers. The new process is the child process and it has a different pid than its parent.
wait()
Allows a parent process to check the running status of the child and wait until it is complete.
Uniprogram Systems
Current program must finish before the next program can be executed.
Multi-programming Systems
CPU switches automatically from process to process. The CPU only runs one process at any given time.
How can several processes share one CPU?
-Fair Scheduling (every process gets to run eventually)
-Protection (different processes cannot modify each other’s state)
-Resource sharing
What is the dispatcher responsible for?
The dispatcher schedules processes. It runs a process for a short period of time then stops the process and saves its state. Finally, the dispatcher loads the state of another process and runs the process.
List the different states of a process
New (give program resources)
Ready (ready for execution)
Active (process currently executing)
Blocked (voluntary stop)
Stopped (involuntary stop)
Exiting (process leaving CPU)
How does the dispatcher regain control of the CPU?
“Sleeping Beauty Approach” - Trust the process to wake up the dispatcher when it is done
“Alarm Clock” - Wake up the dispatcher after a certain amount of time has passed (superior approach)
What is an issue of using the “sleeping beauty approach” to give the dispatcher control of the CPU?
A process may loop indefinitely. Thus, it never finishes so it never wakes up the dispatcher.
Context Switching
OS saves the state of the active process and restores the state of the interrupt service routine (ISR)
Why must the OS disable all interrupts while saving the state of an active process?
If the OS is interrupted, it cannot save the state as it must service the interrupt which could also be interrupted.
What are the 2 ways of creating a new process? Which method is more efficient?
Building a process from scratch
Cloning an existing process
Cloning an existing process is faster as no disk read is necessary.
fork() return values
Returns the PID of the process that was created
Value greater than 0 - parent process
Value = 0 - child process
Value less than 0 - fork() failed
Zombie Process
A process that has completed execution but still has an entry in the PCB
What are the reasons why a process can enter the exiting state?
Normal Completion - exit() or abort called explicitly or implicitly.
Abnormal Termination - programming error, runtime error, I/O error, process killed.