Purposes of an Operating System (OS)

Cambridge (CIE) A Level Computer Science

Contents

settings

Resource Management

  • System loading & kernel
  • CPU scheduling
  • Memory allocation
  • I/O management & DMA
  • Hiding hardware complexity
swap_horiz

Process Management

  • Multitasking & process states
  • Scheduling routines
  • Scheduling algorithms
  • Interrupt handling
  • Kernel operations
memory

Memory Management

  • Paging & segmentation
  • Virtual memory
  • Memory allocation techniques
  • Fragmentation issues
  • Performance optimization

Lesson Objectives

settings

Understand Operating System Purpose

Identify key functions and resource management techniques

理解操作系统的目的和资源管理技术

swap_horiz

Analyze Process Management

Explain multitasking and different scheduling algorithms

分析进程管理和多任务调度算法

memory

Compare Memory Management

Evaluate paging, segmentation, and virtual memory techniques

比较分页、分段和虚拟内存管理技术

Starter Activity

devices

List Your Devices

List all the devices you use that have an operating system

列出你使用的所有有操作系统的设备

computer Computer
smartphone Smartphone
tablet Tablet
watch Smartwatch
tv Smart TV
router Router

help_outline Think About This

What would happen if these devices didn't have an operating system?

如果这些设备没有操作系统会发生什么?

Resource Management

settings What is Resource Management?

The Operating System (OS) is responsible for managing the computer's hardware efficiently to ensure the system runs smoothly

  • speed Maximising performance of the system
  • block Reducing bottlenecks in resource allocation
  • swap_horiz Ensuring multitasking works correctly
Computer Resource Management

category Types of Resources

memory

CPU

Processing power and execution time

sd_storage

Memory

RAM allocation and management

devices

I/O Devices

Input/output operations

storage

Storage

File system management

Start-up and System Loading

power_settings_new Boot Process

looks_one

BIOS Activation

When computer is switched on, BIOS (stored in ROM) runs a bootstrap program

looks_two

Kernel Loading

Bootstrap loads the kernel and essential parts of the OS from storage into main memory (RAM)

looks_3

System Initialization

OS initializes hardware components and prepares the system for user interaction

devices Device Differences

computer

Traditional Computers

Standard boot process with BIOS loading OS from hard disk or flash storage

smartphone

Tablets & Smartphones

Flash memory contains read-only section for the OS and a second section for apps and user data

Desktop Computer Boot Process

Kernel

内核

memory What is the Kernel?

The core of the Operating System that manages all hardware and software resources

操作系统的核心,管理所有硬件和软件资源

Acts as a bridge between applications and hardware, providing essential services

作为应用程序和硬件之间的桥梁,提供基本服务

settings Key Responsibilities

主要职责

swap_horiz

Process Management

进程管理

Schedules processes, allocates CPU time, handles multitasking

sd_storage

Memory Management

内存管理

Allocates RAM, handles virtual memory, prevents clashes

devices

Device Management

设备管理

Controls I/O devices using device drivers

notifications_active

Interrupt Handling

中断处理

Deals with interrupts from hardware components

folder

File Management

文件管理

Handles reading/writing from files and file systems

CPU Resource Management

speed Maximizing CPU Usage

The OS maximizes CPU usage through scheduling, which allows multiple processes to be managed efficiently

  • swap_horiz Multitasking ensures rapid CPU switching between processes
  • schedule Different scheduling algorithms share CPU time fairly
  • auto_graph Optimizes system performance and responsiveness

settings Scheduling Algorithms

Different algorithms are used to allocate CPU time based on system requirements:

loop Round Robin

Equal time slices for all processes

low_priority Priority-based

Higher priority processes get CPU time first

first_page First Come First Served

Simple queue-based approach

timer Shortest Job First

Prioritizes processes with shortest execution time

Memory Resource Management

memory Dynamic Memory Allocation

RAM is dynamically allocated to active programs and system processes

  • swap_horiz Memory shifts between active and inactive applications
  • security Prevents memory conflicts between processes
  • speed Optimizes system performance for multitasking

compare_arrows Virtual Memory Process

When RAM is full, the OS uses virtual memory on disk to simulate extra memory

memory

RAM fills with active processes

arrow_forward
swap_vert

OS moves less-used data to disk

arrow_forward
apps

More programs can run simultaneously

Input/Output Management and DMA

devices I/O Device Management

I/O devices are much slower than the CPU, so the OS optimizes their use:

  • settings I/O operations managed through device drivers and interrupts
  • swap_horiz Buffering techniques to handle speed differences
Device Typical Data Rate
Keyboard ~50 bps
Mouse ~120 bps
Laser printer ~1 Mbps
Hard disk ~100 Mbps

swap_vert Direct Memory Access (DMA)

The DMA controller allows data transfer between memory and devices without CPU involvement

memory

DMA transfers data directly between device and memory

arrow_forward
free_breakfast

CPU is freed to perform other tasks

arrow_forward
notifications_active

DMA sends interrupt when transfer is complete

  • speed Dramatically improves system efficiency
  • trending_up Enables true multitasking capability

Hiding Hardware Complexity

layers Abstraction Layers

The OS provides a user-friendly interface and handles the complexity of interacting with hardware

desktop_windows

Graphical User Interface (GUI)

Makes tasks like file transfers easy (e.g. drag-and-drop instead of command-line)

settings

Device Drivers

Handle communication with specific hardware components

code

APIs & System Calls

Provide standardized interfaces for software to access hardware

compare_arrows Simplifying User Experience

Users don't need to know technical commands, the OS abstracts this complexity

terminal

Without OS

Direct hardware interaction, complex commands, specialized knowledge required

touch_app

With OS

Intuitive interfaces, simplified operations, accessible to all users

  • visibility Creates a consistent experience across different hardware
  • build Enables plug-and-play functionality for new devices
  • security Provides security layers between users and hardware

Resource Management Summary

summarize Resource Management Techniques

Resource Technique Used
memory CPU
schedule Scheduling algorithms (Round Robin, Priority-based)
swap_horiz Multitasking through rapid context switching
settings Process control and priority management
sd_storage Memory
grid_view Allocation to active processes
view_module Paging and segmentation techniques
storage Virtual memory to extend physical RAM
devices I/O
notifications_active Interrupts to signal completion
swap_vert DMA for efficient data transfer
settings Buffering and driver management
desktop_windows User Interface
layers Abstracts complexity through GUI
apps System utilities for user interaction
folder Storage
folder_open File system management
speed Read/write optimization via caching and buffering

Multitasking & Process States

swap_horiz What is Multitasking?

Multitasking is the ability of the OS to manage system resources to give the illusion that multiple programs run simultaneously

  • speed CPU executes one instruction at a time
  • autorenew Processes billions of instructions per second
  • swap_vert Rapid switching between tasks creates the illusion
looks_one

Task 1

CPU executes for a time slice

swap_horiz

Context Switch

State saved, next task loaded

looks_two

Task 2

CPU executes for a time slice

memory What is a Process?

A process is a program in execution with its own allocated resources

code Program Code

Instructions to be executed

storage Current Data

Variables and values in use

settings Register Values

CPU state information

sd_storage Memory Space

Allocated RAM for the process

  • apps Each running application is a separate process
  • change_circle Processes change state based on resource availability

Process States

进程状态

A process does not always run continuously. It changes state depending on what it's doing and whether it has access to resources.

进程并不总是持续运行。它会根据其活动和资源可用性改变状态。

play_arrow

Running

运行中

The process is actively being executed by the CPU

进程正在被CPU主动执行

lightbulb Example

A word processor processing user input as they type

文字处理器处理用户输入

schedule

Ready

就绪

The process is prepared to run but is waiting for the CPU to be available

进程准备运行但等待CPU可用

lightbulb Example

A background application waiting for CPU time to process data

后台应用程序等待CPU时间处理数据

pause

Blocked

阻塞

The process is waiting for an event or resource, such as I/O completion

进程正在等待事件或资源,如I/O完成

lightbulb Example

A browser waiting for a webpage to download from the internet

浏览器等待网页从互联网下载

Scheduling Routines

schedule What is Scheduling?

Deciding which tasks to process, for how long, and in what order through scheduling algorithms

  • speed CPU processes tasks as fast as possible
  • settings Different algorithms for different scenarios
  • compare_arrows Each has unique benefits and drawbacks

category Scheduling Categories

timer Pre-emptive

Allocates CPU for time-limited slots

  • check_circle Can interrupt current processes
  • warning May neglect low-priority tasks
loop Round Robin
timer Shortest Remaining Time

block Non-pre-emptive

Allocates CPU for unlimited time

  • check_circle Process holds CPU until completion
  • warning Long processes block shorter ones
first_page First Come First Serve
schedule Shortest Job First

Scheduling Categories

timer

Pre-emptive

Allocates CPU for time-limited slots

  • schedule Specific time quantum for each process
  • swap_horiz Allows interruption of running processes
  • warning May neglect low-priority processes

list Example Algorithms

loop Round Robin
timer Shortest Remaining Time
block

Non-pre-emptive

Allocates CPU for unlimited time slots

  • lock Process holds CPU until completion
  • not_interested Cannot be interrupted until finished
  • hourglass_full Long processes block shorter ones

list Example Algorithms

first_page First Come First Serve
schedule Shortest Job First

Scheduling Algorithms

loop

Round Robin

Pre-emptive

Equally distributes processor time among all processes

  • schedule Each process gets a time quantum to execute
  • swap_horiz Unfinished processes move to back of queue
  • check_circle Fair distribution of CPU time

visibility Example

P1
arrow_forward
P2
arrow_forward
P3
arrow_forward
P1
Time Quantum
Fixed time for each process
first_page

First-Come-First-Served

Non-pre-emptive

Prioritizes processes that arrive at the queue first

  • queue Process runs until completion
  • block Current process blocks all others
  • add New tasks join the back of queue

visibility Example

P1
arrow_forward
P2
arrow_forward
P3
Arrival Order
Processes served in order they arrive

More Scheduling Algorithms

layers

Multi-Level Feedback Queue

Pre-emptive

Priority algorithm where shorter and more critical tasks are processed first

  • filter_list Multiple queues group similar-sized tasks
  • trending_down Processes trickle down to lower priority queues
  • priority_high Creates prioritization system

visibility Example

Q1: High
arrow_downward
Q2: Med
arrow_downward
Q3: Low
timer

Shortest Job First

Non-pre-emptive

Processes continuously sorted by burst time from shortest to longest

  • sort Shorter jobs placed at front of queue
  • hourglass_bottom Longer jobs have lower priority
  • speed Minimizes waiting time

visibility Example

P1: 3ms
arrow_forward
P2: 5ms
arrow_forward
P3: 8ms
update

Shortest Remaining Time First

Pre-emptive

Pre-emptive version of SJF where processes with shortest remaining time have higher priority

  • timer Time quantum set for each task
  • replay Unfinished tasks re-queued for further processing
  • swap_horiz High context switching overhead

visibility Example

P1: 2ms
arrow_forward
P2: 4ms
arrow_forward
P1: 1ms

Scheduling Algorithms Summary

compare Algorithm Comparison

Algorithm Benefits Drawbacks
loop Round Robin
  • check_circle Fair CPU share for all processes
  • check_circle Good for time-sharing systems
  • check_circle Predictable execution time
  • cancel Difficult to choose optimal time quantum
  • cancel High turnaround time for long processes
first_page First Come First Served
  • check_circle Simple and easy to implement
  • check_circle Fair based on arrival order
  • cancel Poor performance with long processes
  • cancel High-priority tasks wait in queue
layers Multi-Level Feedback Queue
  • check_circle Prioritizes smaller tasks
  • check_circle Groups similar-sized tasks together
  • cancel More complex than other algorithms
  • cancel Setting correct parameters is difficult
timer Shortest Job First
  • check_circle Minimizes waiting time
  • check_circle Efficient for short processes
  • cancel Requires knowing burst time in advance
  • cancel Long processes may starve
update Shortest Time Remaining
  • check_circle Ideal for jobs with short burst times
  • check_circle Pre-emptive for optimal performance
  • cancel Requires knowing burst time in advance
  • cancel High context switching overhead

Memory Management

memory What is Memory Management?

Fundamental role of the OS dealing with allocation and deallocation of the computer's primary memory

  • apps Application data loaded from storage into active memory for smooth execution
  • folder File data loaded alongside application data when opening files
  • priority_high Primary memory is a limited resource requiring careful management

stars Benefits & Techniques

speed Efficient allocation enables multitasking
security Maintains security between processes

Key Techniques

grid_view

Paging

Divides memory into fixed-size blocks

view_module

Segmentation

Divides memory into variable-sized segments

storage

Virtual Memory

Uses disk space as extension of RAM

Paging and Segmentation

grid_view

Paging

Divides memory into fixed-sized blocks (pages)

  • check_circle Facilitates efficient memory management
  • check_circle Enables use of virtual memory
  • warning Can lead to internal fragmentation

visibility Example: 200KB file in 64KB pages

64KB
64KB
64KB
8KB used
56KB unused

Unused space in a page is wasteful as other data cannot be stored there

view_module

Segmentation

Divides memory into variable-sized segments based on logical parts

  • check_circle Allows intuitive memory access
  • check_circle Space-efficient allocation
  • warning Can result in external fragmentation

visibility Example: Video editing application

Video Data
Audio Data
Effects
UI Elements

Physical gaps reduce maximum size of new segments that can be allocated

Virtual Memory and Summary

虚拟内存和总结

storage Virtual Memory

虚拟内存

When computer runs low on primary memory, it can make secondary storage act as an extension of main memory

当计算机主内存不足时,它可以使辅助存储作为主内存的扩展

  • swap_vert
    OS offloads data from RAM to virtual memory

    操作系统将数据从RAM卸载到虚拟内存

  • visibility
    Creates illusion of larger memory

    创建更大内存的错觉

  • warning
    Accessing virtual memory is considerably slower than RAM

    访问虚拟内存比RAM慢得多

sd_storage

RAM

随机存取存储器

Fast, limited capacity

快速,容量有限

swap_horiz
storage

Virtual Memory

虚拟内存

Slower, larger capacity

较慢,容量更大

summarize Memory Management Summary

内存管理总结

Technique Benefits Drawbacks
grid_view Paging 分页
check_circle Efficient memory management
check_circle Enables virtual memory
cancel Internal fragmentation
view_module Segmentation 分段
check_circle Intuitive memory access
check_circle Space-efficient
cancel External fragmentation
storage Virtual Memory 虚拟内存
check_circle Run larger programs
check_circle Effective multitasking
cancel Slower than physical memory
cancel Performance issues if overused

Past Paper Questions

历年考题

quiz

Worked Example

例题解析

(a) Explain what is meant by virtual memory.

(a) 解释什么是虚拟内存。

Virtual memory, paging and segmentation are used in memory management.

虚拟内存、分页和分段用于内存管理。

check_circle

Answer

答案

storage Disk/secondary storage extends RAM
memory More memory space than available RAM
swap_horiz Data swapped between RAM and virtual memory

磁盘/辅助存储用于扩展RAM,使CPU看起来能访问比可用RAM更多的内存空间。只有使用中的数据需要在主内存中,因此数据可以根据需要在RAM和虚拟内存之间交换。

(b) State one difference between paging and segmentation in the way memory is divided.

(b) 说明分页和分段在内存划分方式上的一个区别。

check_circle

Answer

答案

grid_view Paging: fixed-size blocks
view_module Segmentation: variable-sized blocks
speed Paging: faster access times

分页允许内存被划分为固定大小的块,而分段将内存划分为可变大小的块。操作系统将内存划分为页,编译器负责计算段的大小。分页的访问时间比分段快。

Exit Ticket

离场券

assignment_turned_in

Quick Assessment

快速评估

Test your understanding of operating systems

测试你对操作系统的理解

1

What is the main purpose of an operating system?

操作系统的主要目的是什么?

Hint: Think about resource management

提示:考虑资源管理

2

Name two resource management techniques

说出两种资源管理技术

Hint: Consider CPU, memory, and I/O

提示:考虑CPU、内存和I/O

3

Explain the difference between pre-emptive and non-pre-emptive scheduling

解释抢占式非抢占式调度的区别

Hint: Think about time allocation

提示:考虑时间分配

4

What is the main difference between paging and segmentation?

分页分段的主要区别是什么?

Hint: Consider block sizes

提示:考虑块大小

info

Complete these questions on a separate sheet and submit before leaving. This will help assess your understanding of today's lesson.

在单独的纸上完成这些问题并在离开前提交。这将有助于评估你对今天课程的理解。