6.1.5 – 6.1.9 – Role Of The Operating System

6.1.5 – Explain the role of the operating system in terms of managing memory, peripherals and hardware interfaces

Why do we need an Operating System (OS)?

An operating system is defined as ”the software that supports a computer’s basic functions, such as scheduling tasks, executing applications, and controlling peripherals.”

Operating systems are pretty awesome!

They can be classed as ……

  • Single user
  • Multi User
  • Multi Processing
  • Multitasking
  • Multithreading

Most OS systems are generally written in C or C++ whilst older ones were written in assembly language. A few of the critical operations that are really important for the performance of the OS are still written in assembly language

Examples of the above include :

  • Processor and Feature Identification
  • Device driver interfaces
  • Interrupt handling

All operating systems are collections of software that belong to the system software

The OS is a system and the collection of software all form to contribute towards a common goal

Any computer is a collection of hardware & software resources that provide IPO services (Input, Process, Output)

OS is the core software that coordinates all the resources that are needed by the user/system.

The OS controls execution of all other software (It can locate the application on the HD, calculate the amount of RAM needed to run, allocate the RAM to the application, copy the application to the RAM …and so on)

Functions of the operating System can easily be remembered as :

Short People Must Never Run Downhill!

  • Security
  • Peripheral Communication
  • Memory Management
  • Networking
  • Resource monitoring and multitasking
  • Disk access and data management

6.1.7 – Outline OS resource management techniques: scheduling, policies, multitasking, virtual memory, paging, interrupt, polling

  • RAM is much smaller compared to Secondary Storage (HDD)
  • Memory management is managing computer memory & instructions that are executed in the (ALU) that was loaded from the RAM and not the hard drive directly.
  • RAM is scarce and needs to be managed efficiently In order to achieve the best possible performance.
  • Only vital data should be help in the RAM
  • Programs that finish should return the memory that they had been allocated (This is the OS jobs to ensure this happens) otherwise the resources will not free up for other programs to use. This problem is called memory leak or resource leak

Slicing

Slicing is used by Multitasking systems to effectively manage all running programs.

A slice or a time–slice is allocated to each element (whether that be a user or a program)

Polling

“In polling CPU keeps on checking I/O  devices at regular interval whether it needs CPU service”

Polling is the periodic checking of a device by a central device to sample their status

For example, when a printer is connected via a parallel port, the computer periodically checks and waits until the printer has received the next character.

A good example between Polling and Interrupts is:

“Polling is when one checks his/her smartphone periodically to see if a notification has come up & Interrupt is when a notification arrives to ones smartphone and the smartphones notification ringer sounds.”

Interrupt

“In digital computers, an interrupt is an input signal to the processor indicating an event that needs immediate attention.”

The OS uses an interrupt which suspends a process then is executed by the ALU and uses a mechanism to determine the next process to be executed

The interrupt handler as the name suggests is scheduled to allow the OS to switch between processes when their slice times expire.

An example could be that when a printer runs out of papers a “printer unavailable” message interrupt the current task.

Scheduling

Scheduling is as the name suggests a way of scheduling tasks to be completed in a determined manner.

  • First come first serve (FCFS)
    In this scheduling algorithm the first process entered in queue is processed first.
  • Shortest job first (SJF)
    In this scheduling algorithm the process which requires shortest CPU time to execute is processed first.
  • Shortest Remaining Time First (SRTF) scheduling
    This scheduling Algorithm is the preemptive version of the SJF scheduling algorithm. In this, the process which is left with the least processing time is executed first.
  • Longest Job First (LJF)
    In this type of scheduling algorithm, the process with the maximum time required to execute is scheduled first. In this type of scheduling is not widely used because it is not a very effective way of scheduling, as the average turn-around time and the average waiting time are maximum in this case.
  • Longest Remaining Time First (LRTF)
    As SRTF is to SJF, LRTF is the preemptive version of the LJF scheduling algorithm.
  • Priority scheduling
    In this scheduling algorithm the priority is assigned to all the processes and the process with highest priority executed first. Priority assignment of processes is done on the basis of internal factor such as CPU and memory requirements or external factor such as user’s choice. The priority scheduling algorithm supports preemptive and non – preemptive scheduling policy.
  • Round Robin (RR) scheduling
    In this algorithm the process is allocated the CPU for the specific time period called time slice, which is normally of 10 to 100 milliseconds. If the process completes its execution within this time slice, then it is removed from the queue otherwise it has to wait for another time slice.

Policies

Policies are ways to choose which activities to perform.

The policies is what is to be done while the mechanism specifies how it is to be done.

For example

Most cases more than one user has access to a personal computer or on a network thousands of people who have access to a large amount of data.

OS is responsible for creating each user account to access computer or network.

The user account defines the privileges and rights of a particular user.

Virtual Memory

Virtual memory is a feature of an operating system (OS) that allows a computer to compensate for shortages of physical memory by temporarily transferring pages of data from random access memory (RAM) to disk storage.

Swapping

Swapping is the general term in which a processor block of program can be swapped out of RAM into a hard disk and then later brought back into RAM to continue their execution

Paging

Paging is a key component of virtual memory implementation and allows operating systems to use secondary storage as if it was RAM.

The OS copies as much data as it can into the RAM and leaves the rest of the hard disk.

When the OS required data from the hard disk  it exchanges some data  in RAM (known as a page) with the required data on disk.

It works well but excessive page swapping leads to what is known as “thrashing” (poor system performance)

Paging Vs Swapping in a nutshell

The main difference between swapping and paging is that, in swapping, the processes move back and forth between the main memory and secondary memory while, in paging, equal size memory blocks, called pages, move between the main memory and the secondary memory.

Difference Between Swapping and Paging - Comparison Summary

6.1.8 – Discuss the advantages of producing a dedicated operating system for a device

Dedicated operating systems are custom made to do a specific function at maximum efficiency.

By having a custom OS you can eliminate certain aspects of the OS which are not needed, reducing the size of the OS, therefore reducing the amount of secondary memory and RAM being used.

There are 2 general ways to approach developing a dedicated OS

The first is to take an existing operating system and adapt it.

  • The Advantage being that the end user will be familiar with the interface
  • The disadvantage is that it may not be optimized to its best potential for the purpose it was given.

The second approach is to design the OS to fit the needs of the device exactly

  • The advantage is that the system will be optimized the device in terms of size, efficiency, etc)
  • The disadvantage is it can not be used on other devices and can often be expensive to make as it would be considered bespoke

6.1.9. – Outline how an operating system hides the complexity of the hardware from users and applications

GUI (Graphical User Interface)

Drive letters make it simple to select drive.

Folder structures by just clicking icon. Users can even disable/change hardware using icons and sliders

Can change virtual memory by just selecting slider or type in amount (very simple – abstraction to remove complicated elements uImagine trying to do any of these above tasks using MS-DOS or the IOS terminal

Due to this abstraction, users cannot see changes in the hardware. It can be used is to make related devices appear the same from the user’s point of view.

For example, hard disks, floppy disks, CD-ROMs, and USB keys are all very different media, but in many OS they appear the same to the user.