Tidy up
This commit is contained in:
103 files changed
+3663
-3779
No files matched your search
@@ -1,50 +1,52 @@
|
||||
05/10/20
|
||||
---
|
||||
The OS is responsible for *managing* and *scheduling processes*
|
||||
>Decide when to admit processes to the system (new -> ready)
|
||||
> Decide when to admit processes to the system (new -> ready)
|
||||
>
|
||||
>Decide which process to run next (ready -> run)
|
||||
> Decide which process to run next (ready -> run)
|
||||
>
|
||||
>Decide when and which processes to interrupt (running -> ready)
|
||||
> Decide when and which processes to interrupt (running -> ready)
|
||||
|
||||
It relies on the *scheduler* (dispatcher) to decide which process to run next, which uses a scheduling algorithm to do so.
|
||||
|
||||
The type of algorithm used by the scheduler is influenced by the type of operating system e.g. real time vs batch.
|
||||
The type of algorithm used by the scheduler is influenced by the type of operating system, e.g. real-time vs batch.
|
||||
|
||||
**Long Term**
|
||||
|
||||
- Applies to new processes and controls the degree of multi-programming by deciding which processes to admit to the system when:
|
||||
- A good mix of CPU and I/O bound processes is favourable to keep all resources as bust as possible
|
||||
- A good mix of CPU and I/O bound processes is favourable to keep all resources as busy as possible
|
||||
- Usually absent in popular modern OS
|
||||
|
||||
**Medium Term**
|
||||
|
||||
>Controls swapping and the degree of multi-programming
|
||||
> Controls swapping and the degree of multi-programming
|
||||
|
||||
**Short Term**
|
||||
|
||||
- Decide which process to run next
|
||||
- Manages the *ready queue*
|
||||
- Invoked very frequency, hence must be fast
|
||||
- Usually called in response to *clock interrupts*, *I/O interrupts*, or *blocking system calls*
|
||||
- Manages the *ready queue*
|
||||
- Invoked very frequently, hence must be fast
|
||||
- Usually called in response to *clock interrupts*, *I/O interrupts*, or *blocking system calls*
|
||||
|
||||

|
||||
|
||||
**Non-preemptive** processes are only interrupted voluntarily (e.g. I/O operation or "nice" system call `yield()`)
|
||||
>Windows 3.1 and DOS were non-preemptive
|
||||
**Non-preemptive** processes are only interrupted voluntarily (e.g. an I/O operation or the "nice" system call `yield()`)
|
||||
> Windows 3.1 and DOS were non-preemptive
|
||||
>
|
||||
>The issue with this is if the process in control goes wrong or gets stuck in a infinite loop then the CPU will never regain control.
|
||||
> The issue with this is that if the process in control goes wrong or gets stuck in an infinite loop, the CPU will never regain control.
|
||||
|
||||
**Preemptive** processes can be interrupted forcefully or voluntarily
|
||||
**Pre-emptive** processes can be interrupted forcefully or voluntarily
|
||||
|
||||
>This required context switches which generate *overhead*, too many of them show me avoided.
|
||||
> This requires context switches, which generate *overhead*. Too many of them should be avoided.
|
||||
>
|
||||
>Prevents processes from monopolising the CPU
|
||||
> Prevents processes from monopolising the CPU
|
||||
>
|
||||
>Most popular modern OS use this kind.
|
||||
> Most popular modern OS use this kind.
|
||||
|
||||
Overhead - wasted CPU cycles
|
||||
How can we objectively critic the OS?
|
||||
How can we objectively critique the OS?
|
||||
|
||||
**User Oriented criteria**
|
||||
**User-Oriented Criteria**
|
||||
*Response time* minimise the time between creating the job and its first execution (time between clicking the button and it starting)
|
||||
*Turnaround time* minimise the time between creating the job and finishing it
|
||||
*Predictability* minimise the variance in processing times
|
||||
@@ -57,6 +59,7 @@ How can we objectively critic the OS?
|
||||
> Are some processes kept waiting excessively long - **starvation**
|
||||
|
||||
### Different types of Scheduling Algorithms
|
||||
|
||||
[NOTE: FCFS = FIFO]
|
||||
|
||||
**First come first serve**
|
||||
@@ -64,27 +67,27 @@ Concept: a non-preemptive algorithm that operates as a strict queuing mechanism
|
||||
|
||||
| Pros | Cons |
|
||||
| ----------- | ----------- |
|
||||
| Positional fairness | Favours long processes over short ones (think supermarket checkout) || |
|
||||
| Positional fairness | Favours long processes over short ones (think supermarket checkout) |
|
||||
| Easy to implement | Could compromise resource utilisation |
|
||||
|
||||

|
||||
|
||||
**Shortest job first**
|
||||
A non-preemptive algorithm that starts processes in order of ascending processing time using a provided estimate of the processing
|
||||
A non-pre-emptive algorithm that starts processes in order of ascending processing time using a provided estimate of the processing time.
|
||||
|
||||
| Pros | Cons |
|
||||
| ----------- | ----------- |
|
||||
| Always results an optimal turnaround time | Starvation might occur |
|
||||
| Always results in an optimal turnaround time | Starvation might occur |
|
||||
| - | Fairness and predictability are compromised |
|
||||
| - | Processing times need to be known in advanced |
|
||||
| - | Processing times need to be known in advance |
|
||||
|
||||

|
||||
|
||||
**Round Robin**
|
||||
A preemptive version of FCFS that focuses context switches at periodic intervals or time slices
|
||||
A pre-emptive version of FCFS that focuses context switches at periodic intervals or time slices.
|
||||
|
||||
>Processes run in order that they were added to the queue.
|
||||
>Processes are forcefully interrupted by the timer.
|
||||
> Processes run in order that they were added to the queue.
|
||||
> Processes are forcefully interrupted by the timer.
|
||||
|
||||
| Pros | Cons |
|
||||
| ----------- | ----------- |
|
||||
@@ -93,20 +96,20 @@ A preemptive version of FCFS that focuses context switches at periodic intervals
|
||||
| - | Can reduce to FCFS |
|
||||
|
||||
Exam 2013: Round Robin is said to favour CPU bound processes over I/O bound processes. Explain why this may be the case.
|
||||
>I/O processes will spend a lot of their allocated time waiting for data to come back from memory, therefore less processing can occur before the time slice runs out.
|
||||
> I/O processes will spend a lot of their allocated time waiting for data to come back from memory, therefore less processing can occur before the time slice runs out.
|
||||
|
||||
If the time slice is only used partially the next process starts immediately
|
||||
The length of the time slice must be carefully considered.
|
||||
>A small time slice (~ 1ms) gives a good response time.
|
||||
>A large time slice (~ 1000ms) gives a high throughput.
|
||||
> A small time slice (~ 1ms) gives a good response time.
|
||||
> A large time slice (~ 1000ms) gives a high throughput.
|
||||
|
||||

|
||||
|
||||
**Priority Queue**
|
||||
A preemptive algorithm that schedules processes by priority
|
||||
A pre-emptive algorithm that schedules processes by priority.
|
||||
|
||||
>A round robin is used for processes with the same priority level
|
||||
>The process priority is saved in the process control block
|
||||
> A round robin is used for processes with the same priority level
|
||||
> The process priority is saved in the process control block
|
||||
|
||||
| Pros | Cons |
|
||||
| ----------- | ----------- |
|
||||
@@ -117,8 +120,9 @@ You could give higher priority processes a larger time slice to improve efficien
|
||||
|
||||

|
||||
|
||||
Exam Q 2013: Which algorithms above lead to starvation?
|
||||
>Shortest job first and highest priority first.
|
||||
Exam Q 2013: Which algorithms above lead to starvation?
|
||||
> Shortest job first and highest priority first.
|
||||
|
||||

|
||||
|
||||

|
||||
Reference in new issue
Block a user