Objectives

Students will be able to:

  • understand the functions of an operating system

Scheduling

 

Remember all of those processes you saw in the practical activity? There is only one CPU to handle all of them!

How can the CPU prioritize which processes to handle first?

Actually, it's the Operating System that allocates CPU Time to processes.

Here are some common scheduling algorithms used by operating systems.

First come, First served

Processes join a queue and are processed as first come, first served. There is no prioritising. Once a process has been served by the CPU, the next process in the queue is handled.

Round Robin

Every process is given an equal amount of CPU time. The first process in the queue is handled for the given amount of CPU time and if the process's execution is not complete at the end of the time period it is sent to the back of the queue. The next process is given the same amount of CPU time and the cycle continues. This scheduling algorithm is cyclic in nature.

Priority scheduling

High priority processes are identified in the queue and processed first. In some systems, a low priority process may be suspended and sent to the back of the queue if a high priority process joins the queue.

Multi level queue scheduling

A queue is divided into several separate queues, each with its own scheduling algorithm and priority level. Scheduling between the queues can be determined by priority, or round-robin can be used.

A big challenge for the operating system is optimizing the performance of the system, especially when there are thousands of processes waiting in a queue to be managed, some simple, some complex, some high priority, some low priority.

Security

Scenario

In a school network

  • students log in to gain access to the system and network resources
  • teachers have additional permissions eg deleting or viewing certain files and folders
  • only IT administrators can change system settings

The operating system manages these security controls.

The operating system controls access to a system via authentication (eg username/password, biometrics).

The operating system controls access rights to files, folders and system settings.

The operating system keeps appliactions seperate from each other in memory. If one application is affected by malware, it should affect other applications.

Memory Manager

The operating system is responsible for managing the computer's memory.

When a program is loaded, the operating system allocates memory in RAM for the program's instructions and data.

As the program runs, the operating system may allocate additional memory if needed.

When the program is closed, the operating system deallocates the memory, making it available for other programs and processes.

Accounting

Scenario

A SAAS company provides an online service, allowing thousands of companies and schools to:

  • store files online
  • edit documents
  • upload images
  • collaborate in real time

All of this uses computing resources such as:

  • storage space
  • CPU processing time
  • memory
  • internet bandwidth

The service provider cannot simply allow unlimited usage because resources cost money.

The operating system continuously monitors and records resource usage for each customer.

This process is called accounting.

For example, the system may record:

  • how much storage a company/school uses
  • how many users are logged in
  • how much bandwidth is consumed
  • how much processing time is required

Accounting is a function of the operating system that monitors and records the use of system resources and user activity. In SaaS systems, accounting information may be used for performance monitoring, security, fair resource allocation, and customer billing based on resource usage.

Virtualization

Scenario

A school needs to provide several network services for students and teachers:

  • a file server for storing documents
  • a web server for the school website
  • a database server for student records

Traditional Approach

The school might purchase three separate physical servers:

Physical Server Purpose
Server 1 File server
Server 2 Web server
Server 3 Database server

Each server has its own:

  • CPU
  • RAM (primary memory)
  • SSD (secondary memory)
  • operating system
  • power supply

This approach produces high costs and potentially wasted resources. For example, the File Server only uses 10% of CPU capacity and 20% of its memory.

They also take up a lot of physical space in the IT Administator's office!

A neat solution to these problems is to take a Virtualized approach.

Instead, the school buys one powerful physical server and uses virtualization software (a hypervisor) to create three virtual machines (VMs).

Virtual Machine Purpose
VM1 File server
VM2 Web server
VM3 Database server
 

Each VM behaves like a separate computer with:

  • its own operating system
  • allocated memory
  • virtual storage
  • applications

Virtualization allows multiple virtual computers to run on a single physical server. This reduces hardware costs, improves resource utilization, simplifies maintenance, and provides flexibility while still allowing services to operate independently.

In a virtualized system, the operating system (or specialized virtualization software called a hypervisor) is responsible for managing and allocating hardware resources such as CPU time, memory, and storage to each virtual machine. It ensures that each VM operates as though it were an independent computer while sharing the same physical hardware safely and efficiently.

The users do not notice that the machines are virtual.

Networking

Networking functions of an operating system allow computers and devices to communicate over networks.

The operating system manages network connections, supports communication protocols eg TCP/IP, enables resource sharing eg network printers, and helps provide secure access to network services such as File servers.

Interrupt vs Poll

Sometimes a hardware device, such as a printer, needs attention from the CPU.

Two common strategies are used to manage this communication:

  • interrupts
  • polling

With interrupts, a device sends a signal to the CPU when it requires attention. The operating system temporarily pauses the current task and handles the interrupt, often giving it priority.

The other strategy is polling. In polling, the CPU repeatedly checks devices at regular intervals to see whether they need attention.

Polling is generally less efficient because the CPU wastes time checking devices even when no action is required.

operating systems

 

Your computer's operating system i sits beating heart.

Without it, your computer would maybe not be dead... but would certainly resemble a zombie.

It is responsible for so many... operations!

To get started, let's do a little OS Appreciation activity.

Key Concepts

 

HL Extension

Further reading

Resource Contention and Deadlock

Resource contention is a natural part of a computer system.

Many processes want to use the same resource eg CPU Time at the same time.

The Operating System manages this by using schduling algorithms and forcing processes to wait their turn for CPU Time.

However, imagine a scenarion where Process A is using the printer. Process B is using the scanner.

Process A needs access to the scanner before it can continue, but Process B needs it too and doesn't release it.

Process B needs access to the printer before it can continue, but Process A needs it too and doesn't release it.

A deadlock occurs when two or more processes are permanently blocked because each process is waiting for a resource that another process is holding.

As a result:

  • none of the processes can continue
  • none release their resources because they are still needed
  • and the system becomes stuck unless the operating system intervenes

The OS needs to intervene when deadlock occurs.

Past Paper Questions