,System software:
Operating Systems:
An Operating System is a collection of programs that work together to provide an interface between
a user and computer. They enable the user to communicate with the computer and perform certain
tasks involving the management of memory and resources, therefore are essential in devices, such
as laptops, phones and consoles. Operating Systems provide:
Memory management (paging, segmentation, virtual memory)
Resource management (scheduling)
File management (moving, editing, deleting files and folders)
Input/output management (device drivers)
Interrupt management
Utility software (disk defragmenter, backup, formatting, etc.)
Security (firewall)
User interface
Memory Management:
Computer memory must be fairly shared between multiple different programs and applications that
are being used. Often, main memory can’t store all the programs being used. The Operating System
determines and allocates the length of processor time each task receives using paging, segmentation
and virtual memory.
Paging:
Paging is when memory is split into equal-sized sections called pages. Programs are made up of a
certain number of equally-sized pages, which can be swapped between main memory and the Hard
Disk Drive when needed.
Segmentation:
Segmentation is the splitting of memory in logical sized divisions that are known as segments. They
vary in size and are representative of the structure and logical flow of the program. Each segment is
allocated to blocks of code, such as conditional statements or loops.
if block while loop
Virtual Memory:
Virtual memory uses a section of the hard drive to act as Random Access Memory when the main
memory has insufficient space to store programs that are being used. Sections of programs that
aren’t currently being used are temporarily stored in virtual memory using paging.
The issue with these techniques is disk thrashing, which is when the computer freezes, due to pages
being swapped too frequently. As a result, more time is spent transferring the pages than running
the program.
Interrupts:
Interrupts are signals that are generated by the software or hardware to indicate that a process
needs attention. Different types of interrupts have different priorities which the Operating System
uses to allocate processor time. They are stored in a priority queue in an interrupt register.
, 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 with higher priority than the current process, the current contents are
temporarily transferred to a stack. The processor loads the appropriate interrupt Service Routine
(ISR) into Random Access Memory and a flag is set to signal the ISR has begun.
Once the interrupt has been services, the flag is reset and the interrupt queue is checked again. If
there are more interrupts to be service, the process is repeated until all priority interrupts have been
serviced. If there are no higher priority interrupts, the contents of the stack are transferred back to
the registers in memory and the Fetch-Decode-Execute cycle resumes as before.
Scheduling:
Another function of the Operating System is to ensure that all sections of programs being run
receive a fair amount of processing time. This is done using various scheduling algorithms which
work in different ways. They can either be:
1. Pre-emptive: Jobs are actively made to start and stop by the Operating System.
2. Non-pre-emptive: Once a job is started, its left alone until it is completed.
Round Robin:
Each job is given a section of processor time, which is known as a time slice. Within this time frame,
is the allocated time to execute. Once each job within the queue has used its first time slice, the
Operating System grants each job another equal slice of processor time. This continues until a job is
completed, after which it is removed from the queue. Although Round Robin ensures that each job is
completed, longer jobs will take much longer to complete, due to the execution being inefficiently
split into multiple cycles. This algorithm also doesn’t take job priority into account.
First Come First Served:
In the First Come First Served scheduling algorithm (also known as First in First out) jobs are
processed in the order that they enter the queue. Although it’s simple to implement, First Come First
Served doesn’t allocate processor time based on priority.
Multilevel Feedback Queues:
Multiple Feedback Queues makes use of multiple queues, each is ordered based on job priorities.
This can be difficult to implement, due to deciding which job to prioritise, based on a combination of
priorities.
Shortest Job First:
Shortest Job First stores jobs to be processed according to the time that is required for completion.
The longest job will be serviced at the end. This type of scheduling is most suited to batch systems
where shorter jobs are given preference to minimise waiting times. However, it requires the
processor t know or calculate how long each job requires which isn’t always possible. There is also a
risk of processor starvation which is when a particular process doesn’t receive enough processor
time in order to execute and be completed. This is caused if short jobs are continued to be added to
the queue.
Shortest Remaining Time:
Shortest Remaining Time stores jobs based on their time with the jobs with the least time to
completion being serviced first. Similar to Shortest Job First, there is a risk of processor starvation.