Virtual Memory
Virtual memory uses a section of the hard drive to act as RAM when the space in main
memory is insufficient to store programs being used. Sections of programs not currently
being used are temporarily moved into virtual memory through paging, freeing up memory
for other programs in RAM.
The key issue with using these techniques is disk thrashing. This is when the computer
‘freezes’ due to pages being swapped too frequently between the hard disk and main
memory. This issue becomes progressively worse as virtual memory is filled up.
Interrupts
Interrupts are signals generated by software or hardware to indicate to the processor that
a process needs attention. Interrupts have different priorities and how urgent they are must
be taken into account by the operating system when allocating processor time. They are
stored within an abstract data structure called a priority queue in an interrupt register.
Examples of interrupts include a printer signalling the completion of a print job or a
peripheral signalling power failure.
Interrupt Service Routine
The processor checks the contents of the interrupt
register at the end of each Fetch-Decode-Execute cycle.
If an interrupt exists that is of a higher priority to the
process being executed, the current contents of the
special purpose registers in the CPU are temporarily
transferred into a stack. The processor then responds to
the interrupt by loading the appropriate interrupt service
routine (ISR) into RAM. A flag is set to signal the ISR has
begun.
Once the interrupt has
been serviced, the flag is
reset. The interrupt queue
is checked for further
interrupts of a higher
priority to the process that
was originally being executed. If there are more interrupts to
be serviced, the process described above is repeated until all
priority interrupts have been serviced. Otherwise, the
contents of the stack are transferred back into the registers in
memory. The Fetch-Decode-Execute cycle resumes as before.