Operating Systems
Introduction I
Aslam Safla
aslam@cs.uct.ac.za
OS Module Overview
2
Introduction and OS Structures (Chapters 1-2).
Processes and Threads (Chapters 3-4).
Process Synchronization, Scheduling, Deadlocks (Chapters 5-8)
Main and Virtual Memory (Chapters 9-10).
File-Systems and I/O (Chapters 11-15).
Protection (Chapter 17).
OS Module Textbook
Operating System Concepts – 10th Edition (2018):
Avi Silberschatz
Peter Baer Galvin
Greg Gagne
John Wiley & Sons, Inc.
ISBN 978-1-118-06333-0
https://codex.cs.yale.edu/avi/os-book/OS10/index.html
OS1 Practical Assignment
4
Assignment: (Closed Practical):
Memory management – Paging algorithms.
60-minute slots: 21th / 22nd of April.
Approx. 7.5% of course mark.
Check Amathuba for updates and sign-up
procedure!
Why Study Operating Systems (OS)?
5
OS are fundamental to CS:
Most people use a handful of mature OS.
Hard to get people to switch OS.
Hard to have impact with a new OS.
Resource consumption is an OS issue:
Battery life, radio spectrum, …
Security is an OS issue.
New “smart” devices need new OS.
6
What is an
Operating System?
7
8
Is an
Operating System (OS)
just a program?
9
OS = Program!
10
UNIX OS (1972): Rewritten in C to move UNIX kernel code from
assembly to high level language (do same tasks with less code).
Microsoft Windows:
MS Windows kernel developed mostly in C (some in assembly).
Mac OS:
OS X kernel is written mostly in C.
Mobile
iOS, Android and Windows Phone kernels: Coded in C (just mobile
adaptations of existing Mac OS, Linux and Windows kernels).
Custom Operating Systems
11
Nintendo Switch system software, aka: Horizon (2017):
Written in C, C++, proprietary microkernel architecture.
Closed source.
OS = The First Program
12
A program that lets you run other programs.
A program providing controlled access to resources:
CPU.
Memory.
Devices: Display, keyboard, mouse.
Persistent storage.
Network.
System Software
13
General piece of software with common functionalities
that support many applications.
Examples:
C compiler and library functions.
Database management system.
OS: Software that operates directly with system
hardware.
An OS is like these things…
14
OS = Illusionist Government !?
15
OS as an illusionist:
Clever resource management to overcome hardware
limitations.
OS as a government:
Protects users from one another.
Allocates resources efficiently and fairly.
Provides an environment within which other programs
can do useful things.
16
OS: System View
OS is a resource allocator:
Manages all resources.
Handles conflicting requests for efficient & fair
resource use.
OS is a control program:
Controls execution of programs – prevent errors –
ensures programs run.
An OS is an Abstraction
17
Interface: Between users and computer (hardware).
Convenience: Hides tedious stuff.
Efficiency and Control: Allocates resources, allows
parallel applications, protects information.
Reality versus Abstraction
Reality
Abstraction
A single CPU
Multiple CPUs
Limited RAM capacity
Infinite capacity
Mechanical/SSD disk
Memory speed access
Insecure and
unreliable networks
Many physical
machines
Reliable and secure
A single machine
19
Why have
Abstractions?
20
Why have Abstractions?
21
Reduce functional complexity.
Provide single abstraction over multiple devices.
Resource sharing:
Efficiency.
Fairness.
Security.
22
Example I: User Abstractions
End User
View
Application
Developer View
System
Developer View
Example II: Disk Abstractions
23
Direct
control
write()
abstraction
fprintf()
abstraction
Example III: Process Abstraction
24
25
OS Abstractions
Hardware
Disks
Memory
Processors
Network
Monitor
Keyboard
Mouse
Operating System:
Files
Programs
Threads of control
Communication
Windows, graphics
Input.
Files as an Abstraction of Memory
26
Issues with Files
27
Naming.
Allocating space on disk (permanent storage)
How to organise for fast access and minimise waste.
How to shuffle data between disk and memory
(high-speed temporary storage).
How to handle crashes and (disk / memory) errors.
Programs
28
Memory Sharing
29
Virtual Memory
30
Resource Sharing
31
OS = Kind of Virtual Machine!
32
Hides complexity and limitations of hardware from
application developers.
Applications
Operating system
(virtual machine)
Physical machine
Virtual machine interface
Physical machine interface
Application Virtual Machines
33
Examples?
Application Virtual Machines
34
VMware:
Hypervisors
Java Virtual
Machine (JVM)
Example: Java Virtual Machine
35
36
Concurrency
vs
Parallelism?
Concurrency
37
Parallelism
38
Concurrency vs. Parallelism
39
Concurrency: Can exist on single CPU: Multi-tasking OS.
Parallelism: Speed-up via N computations in parallel.
Problems get tricky when you introduce parallelism:
Multi-core.
Multiple CPUs.
e.g.: C/C++ with MPI parallel processing libraries.
Current popular idea of common shared state between
multiple threads is risky.
Concurrency and Parallelism
40
Historical growth in
single-processor
performance and a
forecast of processor
performance to 2020
What do these have in Common?
41
Von Neumann Computer Architecture
+ Operating System
44
Von Neumann architecture
Main Memory
central
processing
unit
data
+
machine
instructions
Operating
System
abstraction
compilation
global data
+
sequence of
commands
Problems..?
45
Currently ~ 5–15% of the world’s energy is spent in some
form of data manipulation, transmission, or processing.
> 5 billion transistors per chip common-place.
Transistor sizes now approaching 10 nm.
Parallel computing (Multi-core / CPU) now common-place.
Increased overall energy consumption.
Current predictions: “Data processing centres will end up
costing more energy than we have”1
1. https://theconversation.com/data-centres-are-guzzling-up-too-much-electricity-can-we-make-them-more-efficient-235591
New Types of OS?
47
Can we design hardware and software with a
completely different model of computation ?
Neuro-Morphic Computing
48
System architecture emulates brain (neural) structure.
Inherently parallel processing.
Ideal for “biological” machine learning algorithms – e.g.:
speech / facial recognition.
What would a neuro-morphic OS look like?
Quantum Computing
49
Theorised to be exponentially faster than classical computers:
Solving classical hard CS problems (e.g. factorizing integers).
Information stored as quantum bits (qubits).
30 qubits ~ 10 tera-FLOP (1012) computer.
IBM,16 qubit processor1.
What would a Quantum computing OS look like?
1. https://www.sciencenews.org/article/quantum-computers-are-about-get-real
New Types of OS?
50
What would Operating Systems for these
computer architectures look like ?
Reading
Operating System Concepts – 10th Edition (2018):
Chapter 1: Introduction
https://codex.cs.yale.edu/avi/osbook/OS10/index.html