OS Topic 11 - Context Switching Flashcards
Process states
You have seen that an operating system appears to allow many processes to run concurrently, but that in reality it is rapidly s_________ execution among processes.
switching
Process states
In order to perform process switching, the operating system has to keep track of which processes currently exist and which are ready to run.
For each process, the operating system maintains a record called a c_______ b____ which contains relevant information about the process, such as which areas of memory are allocated to it.
context block
Process states
The context block also records the state of the process.
Give an example of one such state.
E.g. Whether the process is running or not.
Process states
If a process initiates an I/O operation what does the operating system typically do?
It suspends the process until the I/O operation completes.
Process states
Why does the OS suspend a process that has initiated an I/O operation until after the operation completes?
Because I/O operations take a much longer time than the main processer, if it were to wait it could be idle for some time.
Process states
A suspended process is said to be ‘b_________’.
blocked
Process states
Once an OS has suspended a process until it has completed it’s I/O operation, what might it do?
Allow another process to be executed.
Process states
In ‘state diagrams’ which shapes are used to represent states?
Ovals
Process states
In ‘state diagrams’ which shapes are used to represent transitions between states?
Arrows
Process states
What happens when the I/O operation completes?
The process that was blocked is no longer blocked and the operating system must update its s_______ to show this.
state
Process states
Once a process has been unblocked the OS can either update its state to r__________, or
to r_________.
running
ready
Process states
Suppose a process starts a lengthy calculation without performing any I/O. If it were to continue to be executed, then it would stop any other processes from being executed. How could the operating system prevent this?
By limiting the maximum amount of time for which a process can run:
it may allow, say, 10 ms. At the end of this time slice or quantum, the operating system will suspend the running process and pick another process to be executed.
Process states
Given that only one process can run at any one time on a single processor, how is it possible for the OS to run a process in order to interrupt a process?
There are two solutions:
- c_____________ multitasking
- p_____________ multitasking.
cooperative multitasking
pre-emptive multitasking
Process states
Cooperative multitasking is a solution whereby all application programs are written so that they p_____________ yield control back to the operating system.
The operating system then gets a chance to decide which process should run next.
periodically
Process states
There are problems with cooperative multitasking: programmers may be tempted to gain extra performance for their application by _____________________________________________
A worse problem is a program containing a bug that results in an endless loop.
It would never _____________________________________________
by breaking the rules and not yielding control
yield control and so could crash the entire machine.
Process states
Pre-emptive multitasking is an alternative solution. It is a way in which the operating system can always pre-empt an executing process and take control of the processor at any time.
It uses a h____________ i_____________ to do this.
A hardware interrupt
Process states
Hardware interrupts
An OS will set a timer to generate r________ i___________ that will interrupt any running process.
regular interrupts
Process states
True or false?
A pre-emptive system may also allow a process to yield control voluntarily.
True