Week 3-4-5 Flashcards
What are monitors
• Allow for a process to have mutual exclusion (prevents simulation access to a shared resource) and the ability to wait for processes to complete
In Java, synchronization is done in two ways. Synchronized ________ and _________
(blocks and methods).
What is the goal of scheduling?
- To give max CPU utilization
* The longer the burst of CPU, the less likely it might happen
When is a process allocated and what is it performed by?
-Performed by the scheduler • Process goes to a wait state • Process is interrupted • Process goes from wait to ready • Process terminates
What is the scheduling criteria?
- CPU usage
- Throughput (jobs completed)
- Turnaround time (time to complete)
- Waiting time (time was waiting)
- Response time (time to start once called)
What are the types of scheduling?
• First come first served
◦ Jobs are executed on first come, first serve basis.
•It is a non-preemptive, pre-emptive scheduling algorithm.
•Easy to understand and implement.
•Its implementation is based on FIFO queue.
•Poor in performance as average wait time is high.
• Shortest job first
◦ This is a non-preemptive, pre-emptive scheduling algorithm.
•Best approach to minimize waiting time.
•Easy to implement in Batch systems where required CPU time is known in advance.
•Impossible to implement in interactive systems where required CPU time is not known.
•The processer should know in advance how much time process will take.
• Round robin
◦ Round Robin is the preemptive process scheduling algorithm.
•Each process is provided a fix time to execute, it is called a quantum.
•Once a process is executed for a given time period, it is preempted and other process executes for a given time period.
•Context switching is used to save states of preempted processes.
Jobs get assigned to the CPU with the _______ priority
highest)
Can an interrupt occur during a critical section?
• An interrupt can happen at any time, so the answer is Yes.
Three Criteria for Critical Section
- Mutual Exclusion - there can be only one process in the critical section
• Progress - if the critical section is empty, and one or more processes are waiting, one gets to go in
• Bounded Wait - if a process is waiting, the other process can only execute the critical section a limited number of times.
User and Kernel Mode are distinguished by what?
- The modes are distinguished by a bit in one of the registers of the CPU.
What is deadlock and what do we do to prevent it?
- When a process is holding something that another process requires
- Prevention - ensure one of the 4 conditions never happens
- Avoidance: extra information before allocating an available resource
- Recovery: enter deadlock state and recover
- Ignore hope it never happens, handle it manually
What are the four conditions that are needed for a deadlock
- Mutex, only a limited number of things can use a certain resource
- Hold and wait - a process has a resource and is waiting for another
- No preemptive - Can’t take a resource that is in use
- Circular wait - Processes are waiting on each other to do things
What is a safe state?
• When there is no possibility of a deadlock happening
How do we terminate a deadlock?
• Terminate the process! Based on priority, compute time and how much resources it is taking up
When do deadlocks occur in a resource allocation graph?
• When there is a circular dependancy