Topic X – Topic Title Module Title
Module: Computer Systems
Topic: 5
Title of Topic: Operating Systems 2
© NCC Education Limited
Operating Systems 2 Topic 5 - 5.2
Scope and Coverage
This topic will cover:
• A generalised model of OS
• Managing computer systems resources
• Functions of a typical modern OS
• Types and examples of OS
• Virtual machines
• Working with OS (users’ and programmers’ points of
view)
Operating Systems 2 Topic 5 - 5.3
Learning Outcomes
By the end of this topic students will be able to:
• Describe the main components of an operating
system.
• Explain the main functions of a modern multi-
tasking operating system.
• Explain the interaction between the operating
system and hardware.
V0.0 Visuals Handout – Page 1
Topic X – Topic Title Module Title
Operating Systems 2 Topic 5 - 5.4
Computer systems - roadmap
In previous topics, reasons that justify the
need for an operating system are given.
Advanced topics
Computer networks Here, we build over the previous topic, as
Embedded systems we cover the various aspects of operating
Digital logic systems that are common to almost all
Computer systems software
types of operating systems.
Computer programs
Numbers and logic The resources such as the memory, CPU
Operating systems 2 time and input/output resources need
Computer systems hardware managing to prevent a chaotic system and
Computer systems allow many tasks using these resources to
function in a secure environment.
Operating Systems 2 Topic 5 - 5.5
What is an operating system?
• An efficient manager of system resources
• A brave security guard
• A meticulous organiser of information
• An arbitrator of transactions with external agents
• An accomplished juggler
• An expert illusionist
Operating Systems 2 Topic 5 - 5.6
What is an operating system?
Processes Users
Operating System
Device
Handlers
Memory
Comms Storage
Devices
V0.0 Visuals Handout – Page 2
Topic X – Topic Title Module Title
Operating Systems 2 Topic 5 - 5.7
A Generalised Model
App 1 App 2 App N
Support Services/Middleware (optional)
Comms
Operating System
Subsystem
Abstraction Layer
Hardware
Operating Systems 2 Topic 5 - 5.8
Functions of an Operating System
• Managing memory
• Managing processes
• Managing input/output
• Managing file systems
• Ensuring system-wide protection
• Interfacing with the users
Operating Systems 2 Topic 5 - 5.9
Managing the Memory
Allocate and Free memory spaces
A4
Allocate A2, 200
Allocate A3, 100 A2
Free A2
A3
s1 s2 s3 A1
Free Allocated Memory
V0.0 Visuals Handout – Page 3
Topic X – Topic Title Module Title
Operating Systems 2 Topic 5 - 5.10
Managing the Process Memory
Process memory allocation
Memory
P2
P2 Memory
P1 P1 Memory
P3 Memory
P3
Operating Systems 2 Topic 5 - 5.11
Managing the Process Memory
Sharing memory spaces - swapping
P2 Memory
P2
Backing
P1 Memory
Store
P1
P2
P3
P3 Memory P3
Memory
Operating Systems 2 Topic 5 - 5.12
Managing the Process Memory
Virtual memory
Memory
P1 Memory (10 MB)
P1
Backing
Store
P2 Memory (80 MB)
P1: 1 GB
P2
P2: 2 GB
V0.0 Visuals Handout – Page 4
Topic X – Topic Title Module Title
Operating Systems 2 Topic 5 - 5.13
Managing the Processes
• Processes are instances of executable
programs in main memory (normally RAM)
• Process states - waiting, ready, running
entry
event completed ready dispatch
timeout
waiting running
event occurred exit
Operating Systems 2 Topic 5 - 5.14
Managing the Processes
Process queues ("round-robin" scheduling)
P3 P2 P1
ready ready running
t0
P1 P3 P2
ready ready running
t1
P2 P1 P3
ready ready running
t2
Operating Systems 2 Topic 5 - 5.15
Managing the Processes
Process queues (processes with priorities)
P3: pr2 P2: pr3 P1: pr1
ready ready running
t0
P3: pr2 P2: pr3 P1: pr1
running ready ready
t1
P3: pr2 P2: pr3 P1: pr1
ready running ready
t2
V0.0 Visuals Handout – Page 5
Topic X – Topic Title Module Title
Operating Systems 2 Topic 5 - 5.16
Managing the Processes
Process queues (pre-emptive scheduling)
P3: pr2 P2: pr3 P1: pr1
ready ready running
t0
P3: pr2 P2: pr3 P1: pr1 Process P1 is
running ready exited terminated
t1
P3: pr2 P2: pr3 P4: pr1 New process P4
ready ready running pre-empts P3
t2
Operating Systems 2 Topic 5 - 5.17
Managing the Input/Output
• A device driver 'hides' hardware details
• OS maintains a table of devices available
Device
Interface
Application API Device Device
Driver
OS
Software Hardware
Operating Systems 2 Topic 5 - 5.18
Managing the Input/Output -
Buffering
How fast is today's processor? How fast is peripheral IO?
Un-buffered IO
Buffered IO
Double buffered IO
Buffer
CPU
Storage
Device
Buffer
OS
V0.0 Visuals Handout – Page 6
Topic X – Topic Title Module Title
Operating Systems 2 Topic 5 - 5.19
Managing the Input/Output -
Spooling
What happens if a program wishes to print but the printer
is busy, e.g. another program is using it?
Prog A
printer
Prog B
spooler
hard
drive
OS
Operating Systems 2 Topic 5 - 5.20
Managing the Input/Output -
Scheduling
Why? Multiple process IO requests cannot be serviced as fast
as they are generated. Hence the Suspended process state.
How? IO scheduling is often based on some critical physical
device characteristics of peripherals, which can be exploited to
implement efficient handling of peripheral resource sharing.
Disk IO scheduling: FCFS (first-come-first-served), SCAN (e.g.
shortest seek time first, all same seek direction requests first).
Printer IO scheduling: FCFS (first-come-first-served), shortest
print job first.
Network IO scheduling : Round-robin, priority, (WRR) weighted
round-robin (classify packets: realtime,file transfer,etc.)
Operating Systems 2 Topic 5 - 5.21
Managing the File System
File system is maintained on backing stores
file1
file2
file3
Directory
Storage Device
V0.0 Visuals Handout – Page 7
Topic X – Topic Title Module Title
Operating Systems 2 Topic 5 - 5.22
Managing the File System
Data is stored on magnetic bulk storage media
platters
read/write heads
spindle rotation: 5400/7200 rpm
Operating Systems 2 Topic 5 - 5.23
Disc access times and data
transfer rates
seek time (ms): Time taken to rotational delay - latency (ms): Time
move the read/write head to taken to rotate the disk under the
the required track head to the correct sector
settling time (ms): Time taken Data transfer rate (kbs): Time taken
to allow head movements to to transfer data from data buffer to the
settle down disc
Total average access time = seek time + rotational delay + data transfer rate
Example: Capacity = 1 TB; Buffer size = 4 MB; Transfer rate = 100
MB/s; Seek time = 9 ms (average); Latency = 4.17 ms (average);
Spindle speed = 7200 rpm
e.g. 8 MB data will be transferred in (9 + 4.17 + 40) = 53.17 msec (approx.)
Operating Systems 2 Topic 5 - 5.24
Managing the File System
• A hierarchy of folders/directories and sub-
folders/sub-directories (nested folders/directories)
• There are special/system folders/directories
• Folders can be created, deleted, re-named
• Folders can be copied to/from
• Folders can have access rights: read-only, write
• Files are normally stored within the folders
• Files can be created, deleted, re-named
• Files can have access rights: read-only, write,
execute
V0.0 Visuals Handout – Page 8
Topic X – Topic Title Module Title
Operating Systems 2 Topic 5 - 5.25
File management – storage
structures
Tree-structured, multi-level, directory organisation is usually
implemented to support flexible file structure management.
Each partition will have its separate tree structure. Also, may
be maintained per user basis (e.g. as in Unix) for security.
root dev apps temp
dirA
source bin lib appA appB dev bin
dirB
progA progB progC progA progB progC
/dev/bin/progC
Operating Systems 2 Topic 5 - 5.26
Managing the File System
File system becomes fragmented after use
fragment
file1
file2 fragment
file3
fragment
Directory
Storage fragment
free used Device
Operating Systems 2 Topic 5 - 5.27
Managing the File System
De-fragmenting the file system (speeds up file
creation, file accesses, wastes less space)
file1
Contiguous
file2 used space
file3
Directory Contiguous
free space
Storage
free used Device
V0.0 Visuals Handout – Page 9
Topic X – Topic Title Module Title
Operating Systems 2 Topic 5 - 5.28
File management – Storage
structures
Boot control block: used by BIOS in PC in order to support
the loading of the rest of the OS into RAM.
Partition control block: contains partition details.
Directory structure: used to organise files.
File control block(FCB): contains file details (known as
"inode" in Unix).
The above structures are maintained on the storage
device. For improved performance, however, they are
usually cashed in RAM and maintained in there.
Operating Systems 2 Topic 5 - 5.29
File management – Strorage
structures
Clusters
The clusters are maintained as linked
lists. This makes processes such as
file search, delete, extend by adding
new clusters, de-fragment and
compress relatively easy to implement.
Disk Drive
How can this drive be de-fragmented?
Operating Systems 2 Topic 5 - 5.30
File management - Sharing
File sharing
Symbolic links: file sharing
Remote file mounting: networked file
system
File system reliability
Journaling file systems (e.g. MS NTFS, Linux
ext3)
Atomic transactions (i.e. either all or nothing)
V0.0 Visuals Handout – Page 10
Topic X – Topic Title Module Title
Operating Systems 2 Topic 5 - 5.31
File management - protection
Protection of the integrity of files is necessary in multi-user
systems (e.g. Unix). This is not a problem in single-user systems
(e.g. DOS). So, what kind of protection can be afforded?
Access rights: read only, write, read/write, execute
User access level: each user can only access files they own.
Group level access: only members of a group can access.
Access control mechanism: access control list (ACL) is used by
the OS to associate each file and directory with such a list. This
list is also maintained in memory for performance purposes.
ACL - owner: the user who created the file; group: a set of users
sharing the file; universe: all other users (public access).
Operating Systems 2 Topic 5 - 5.32
Ensuring system-wide protection
File system protection (access rights)
User authentication (passwords)
Process address space integrity
No direct access to hardware
Secure data transmission (encrypted)
Secure data storage (encrypted)
Secure file systems (encrypted)
Operating Systems 2 Topic 5 - 5.33
Interfacing with the Users
Command line (uses command parser)
e.g. MS-DOS, Unix, Linux
Menu driven
e.g. Hand-held smart devices (PDAs),
mobile phone OS (Symbian OS?)
Touch-screen
e.g. Hand-held smart devices (Symbian
OS?)
Graphical user interface (GUI)
e.g. MS Windows, Apple Mac OS, Linux,
Amiga OS, OS/2
V0.0 Visuals Handout – Page 11
Topic X – Topic Title Module Title
Operating Systems 2 Topic 5 - 5.34
Working with operating systems
As an applications user (lowest privileges)
Run designated (licensed) applications (word
processors, spread sheets, report applications, etc.)
As a software developer (medium privileges)
Run development tools (editors, compilers,
debugging tools, scripts, source control, etc.)
As a system administrator (highest privileges)
Run maintenance routines, power down, boot up,
install applications, patch software, etc.
Operating Systems 2 Topic 5 - 5.35
Virtual machines
Traditional setup
Operating system X runs Operating system Y runs
on hardware platform X on hardware platform Y
Operating Systems 2 Topic 5 - 5.36
Virtual machines
Traditional setup
Operating system X cannot run Operating system Y cannot run
on hardware platform Y on hardware platform X
V0.0 Visuals Handout – Page 12
Topic X – Topic Title Module Title
Operating Systems 2 Topic 5 - 5.37
Virtual machines
Consider Client – Server setup
• Servers are often under utilized
• Cost of servers is multiplied by a number of servers
• Carbon footprint is multiplied by a number of servers
• Maintenance and cooling of several servers are
costly
Consider several servers in one physical machine?
Operating Systems 2 Topic 5 - 5.38
Virtual machines
Enter Virtualization and Virtual Machines…
• Virtualization is an abstraction of physical hardware from
virtual machines
• A Virtual Machine (VM) is a software construct that mimics
the characteristics of a physical machine
• Virtual machines share the resources of hardware they run
on, e.g. processor(s), RAM, storage, network, etc.
• Virtual machines are made up of files. So, it’s easy to
duplicate them by copying the files.
Operating Systems 2 Topic 5 - 5.39
Virtual machines
Let’s virtualize… Type 1 (‘bare metal’) Virtual Machine Manager
For example,
X = Windows OS
Y = Linux OS
Type 1 hypervisor is deployed on a physical host and can
directly control the resources of that host platform for
performance and security considerations.
V0.0 Visuals Handout – Page 13
Topic X – Topic Title Module Title
Operating Systems 2 Topic 5 - 5.40
Virtual machines
Let’s virtualize… Type 2 (hosted) Virtual Machine Manager
For example,
X = Windows OS
Y = Linux OS
Type 2 hypervisor has an operating system between itself and the
hardware platform resources. It relies on the OS to handle all
hypervisor interactions with the host platform.
Operating Systems 2 Topic 5 - 5.41
Quiz
1. A process is a logical entity. Describe what it actually
represents.
2. Explain why a process can transition out of the running state.
3. Explain pre-emptive scheduling of a process.
4. Explain why there is a need for input/output device drivers.
5. Describe how buffering works during data transfers.
6. Data storage devices get fragmented over time. Explain why
this is the case.
7. Describe how operating system locates a file on a storage
device by file name.
8. State what purpose ‘read only' file protection serves.
9. You have a PC, and you wish to evaluate different operating
systems on it. Explain how best go about this.
Operating Systems 2 Topic 5 - 5.42
Topic Summary
• Operating system is an important and complex software in a
modern digital computer system. It is responsible for managing
many finite resources such as memory and CPU time and
making sure all software programs get to share the resources
equitably.
• Without an operating system it would not be possible to safely
run multiple applications at the same time making sure there is
always enough resources available to share between the
applications by utilizing resource sharing mechanisms.
• Operating system also protects the integrity of the computer
system preventing any corruptions to its resources such as file
systems and memory.
V0.0 Visuals Handout – Page 14
Topic X – Topic Title Module Title
Operating Systems 2 Topic 5 - 5.43
References
Davis, W.S. and Rajkumar, T.M. (2005) Operating
Systems - A Systematic View. Sixth edition. Addison
Wesley.
Silberschatz, et. al. (2019) Operating System
Concepts. 10th Edition. Wiley.
Topic 5 – Operating Systems 2
Any Questions?
V0.0 Visuals Handout – Page 15