1.2.1 Flashcards
The need for, function and purpose of operating systems including
Memory Management
Computers often need more memory than is available and so must efficiently manage the available memory and share it between programs.
Paging
- Memory is broken down into equal sized parts called pages.
- Pages are swapped between main and virtual memory.
Segmentation
- Memory is split up into segments.
- Segments can vary in size.
- These segments represent the logical flow and structure of a program.
Virtual Memory
- Part of the hard drive can be used as RAM.
- Access is slower than RAM.
- Paging is used to move sections which are not in active use into virtual memory.
Interrupts
- A signal generated by hardware or software to tell the processor it needs attention.
- Have different priorities.
- Stored with a priority queue in an interrupt register.
Interrupt Service Routine (ISR)
- At the end of the fetch, decode, execute cycle the interrupt register is checked.
- If there is an interrupt with a higher priority than the current task:
- The contents of the registers are transferred into a stack .
- The appropriate (ISR) is loaded into RAM.
- A flag is set, noting that the ISR has begun.
- The flag is reset when the ISR has finished.
- This process repeats until no more interrupts exist.
Round robin
Each process is allocated a certain time-slice of CPU time (5ms in the example right) .
If the process is still running when the time slice expires it is swapped out and added to the back of the queue.
Round robin pros and cons
Pros
- Avoids process starvation.
Cons
- Can be inefficient if the processor is allocated to a process that
is waiting for input or output eg printer to print.
- Overhead in swapping
- Performance depends heavily on the size of the time quantum
selected. If the quantum is very large (infinite), RR is the same
as FCFS.
First come first served (FIFO)
Processes are allocated processor resources in the order in which they are requested.
First come first served (FIFO) pros and cons
Pros
- Easy to implement with a FIFO queue
- No swapping in and out so no overhead
Cons
- A more important process might have to wait for a less
important one to finish which could crash the system.
- Quick jobs may have to wait for a long job to complete.
- A long process could monopolise the CPU.
- Average waiting time may be long. The average waiting time
under a FCFS policy is generally not minimal, and may vary
substantially if the process burst times vary greatly.
Multi-level feedback queues
- Has a number of queues each assigned a different priority level.
- All processes start in top priority queue (FIFO). Processes on a higher priority queue run first.
- If a process uses up its time allotment, its priority is reduced and it will be moved to a lower-priority queue.
- Using this feedback, processes move between queues.
-To prevent processor starvation, after a set interval, all processes are promoted.
- A MLFQ is the most common general CPU-scheduling algorithm as well as being the most complex.
Multi-level feedback queues advantages and disadvantages
Advantages
- A process that waits too long in a lower priority queue may be moved to a higher priority queue.
- No prior knowledge of the job is needed
- Fair and makes progress for long-running CPU-intensive workloads. - For this reason, many systems including Windows operating systems use a form of MLFQ as their base scheduler.
Disadvantages
- Moving the process around queue produces more CPU overhead.
- How many queues should there be? How big should the time slice be per queue?
-How often should priority be boosted in order to avoid starvation?