Introduction
ECE: Introduction to Computer Systems
Instructor: Maria Striki
Overview of Presentation 1
What is an Operating System?
Major OS components
Architectural refresher
2
What is an Operating System
3
Operating System Definition
OS is a resource allocator
Manages all resources
Decides between conflicting requests for efficient and fair resource use
OS is a control program
Controls execution of programs to prevent errors and improper use of
the computer
Operating System Concepts – 9th Edition
1.4
Silberschatz, Galvin and Gagne ©2013
Quiz Question 1: What Is An Operating System?
What Is An Operating System?
a) collection of programs that manages hardware resources
b) system service provider to the application programs
c) link to interface the hardware and application programs
d) all of the above
Answer:
5
Quiz Question 1
What Is An Operating System?
a) collection of programs that manages hardware resources
b) system service provider to the application programs
c) link to interface the hardware and application programs
d) all of the above
Answer: d
6
Quiz Question 2
To access the services of operating system, the
interface is provided by the ___________
a) System calls
b) API
c) Library
d) Assembly instructions
Answer:
7
Quiz Question 2
To access the services of operating system, the
interface is provided by the ___________
a) System calls
b) API
c) Library
d) Assembly instructions
Answer: a
8
Quiz Question 3
Which facility dynamically adds probes to a running
system, both in user processes and in the kernel?
a) DTrace
b) DLocate
c) DMap
d) DAdd
Answer:
9
Quiz Question 3
Which facility dynamically adds probes to a running system, both
in user processes and in the kernel?
a) DTrace
b) DLocate
c) DMap
d) DAdd
Answer: a
DTrace is a comprehensive dynamic tracing framework created by Sun Microsystems for
troubleshooting kernel and application problems on production systems in real time.
Originally developed for Solaris, then ported to several Unix-like systems. DTrace can be
used to get a global overview of a running system, such as: amount of memory, CPU time,
filesystem and network resources used by the active processes, a log of the arguments with
which a specific function is being called, or a10list of the processes accessing a specific file.
What Is An Operating System?
application (user)
operating system
hardware
1. A software layer between the hardware and the application programs/users which
provides a virtual machine interface: easy and safe.
2. A resource manager that allows programs/users to share the hardware resources:
fair and efficient. It controls execution of programs to avoid improper use of the
computer
3. A set of utilities to simplify application development and execution
4. A program that acts as an intermediary between a user of a computer and the
computer hardware
11
Operating System Definition (Cont.)
“The one program running at all times on the computer” is the kernel.
Everything else is either
a system program (ships with the operating system) , or
an application program.
Operating System Concepts – 9th Edition
1.12
Silberschatz, Galvin and Gagne ©2013
What are the goals of an Operating System?
Operating system goals:
1. Execute user programs and make solving user problems easier
2. Make the computer system convenient to use
3. Use the computer hardware in an efficient manner
13
Computer System Structure
Computer system can be divided into four components:
Hardware – provides basic computing resources
CPU, memory, I/O devices
Operating system
Controls and coordinates use of hardware among various
applications and users
Application programs – define the ways in which the system resources are
used to solve the computing problems of the users
Word processors, compilers, web browsers, database systems,
video games
Users
People, machines, other computers
14
Four Components of a Computer System
15
Why Do We Want An OS?
Benefits for application writers
Easier to write programs
See high level abstractions instead of low-level hardware
details
E.g. files instead of disk blocks
Portability
Benefits for users
Easier to use computers
Can you imagine trying to use a computer without the OS?
Safety
OS protects programs from each other
OS protects users from each other
16
Mechanism And Policy
application (user)
operating system: mechanism + policy
hardware
Mechanisms determine how to do something, policies decide what will be done.
Want these separate, for maximum flexibility, in case policies change in the
future.
Mechanisms: data structures and operations that implement an abstraction (e.g. the
buffer cache)
Policies: the procedures that guide the selection of a certain course of action among
alternatives (e.g. the replacement policy for the buffer cache)
Want to separate mechanisms and policies as much as possible
Different policies may be needed for different operating environments
17
Examples of Various Levels of Abstraction
application (user)
operating system: mechanism + policy
hardware
Question 1: How are different programming models actually implemented?
Question 2: How are different programming models abstracted to the User?
What does the user need to do or need to know about (which levels in the hierarchy
of implementation) to be able to run a program in a given model?
Food for thought: Compare the following two examples of programming models:
1) Posix Pthreads,
2) ISPC (Implicit SPMD Program Compiler, while SPMD: Single Program –
Multiple Data).
18
System layers: interface, implementation, interface, ...
Parallel Applications
Abstractions for describing
concurrent, parallel, or
independent computation
Abstractions for
describing
communication
Compiler and/or parallel runtime
“Programming
model”
(way of thinking about
things)
Language or
library
Primitives
/mechanisms
OS system
call API
Operating system
Hardware
Architecture
Micro-architecture (hardware implementation)
Blue italic text:
abstraction/concept
Red italic text: system interface
Black text: system implementation
19
(HW/SW boundary)
Example: expressing parallelism with
pthreads
Abstraction for describing parallel computation:
thread
pthread_create()
pthread library implementation
System call API
OS support: kernel thread management
x86-64
modern multi-core CPU
Blue italic text:
abstraction/concept
Red italic text: system interface
Black text: system
implementation
20
Programming
model
Example: expressing parallelism (ISPC)
Parallel Applications
Abstractions for describing parallel computation:
1. For specifying simultaneous execution (true parallelism)
2. For specifying independent work (potentially parallel)
ISPC language (call ISPC function, foreach construct)
ISPC compiler
System call API
OS support
x86-64 (including AVX vector instructions)
single-core of CPU
Note: This diagram is specific to the ISPC gang abstraction.
21
Programming
model
Basic Computer Structure and Machine
Abstraction of Module Functionalities
to the User
22
Basic computer structure
CPU
Memory
memory bus
I/O bus
disk
Net interface
23
Computer System Organization
Computer-system operation
One or more CPUs, device controllers connect through common
bus providing access to shared memory
Concurrent execution of CPUs and devices competing for
memory cycles
Operating System Concepts – 9th Edition
1.24
Silberschatz, Galvin and Gagne ©2013
Virtual Machine Abstractions
Processes: system abstraction – illusion of being the only job
executing in the system (not quite when want to share)
Threads: CPU abstraction – illusion of having a dedicated CPU
Virtual memory: memory abstraction – illusion of having an
unlimited memory
File system: storage abstraction – illusion of structured, persistent
storage system
Messaging: communication abstraction – illusion of reliable,
ordered communication
Character and block devices: I/O abstraction – standardized I/F
for devices
25
Major Issues In OS Design
Programming API: what should the VM look like?
Resource management: how should resources be shared
among multiple users?
Security: how to protect users from each other? How to
protect programs from each other? How to protect the OS
from applications and users?
Communication: how can applications exchange information?
Structure: how to organize the OS?
Concurrency: how do we deal with the concurrency inherent
in OS’s?
26
Major Issues In OS Design
Performance: how to make it all run fast?
Reliability: how do we keep the OS from crashing?
Persistence: how can we make data last beyond program
execution?
Accounting: how do we keep track of resource usage?
Distribution: how do we make it easier to use multiple
computers in conjunction?
Scaling: how do we keep the OS efficient and reliable as the
imposed load and so the number of computers grow?
27
Storage Management
28
Storage Structure
Main memory – only large storage media that the CPU can access
directly
Random access
Typically volatile
Secondary storage – extension of main memory that provides large
nonvolatile storage capacity
Hard disks – rigid metal or glass platters covered with magnetic
recording material
Disk surface is logically divided into tracks, which are subdivided into sectors
The disk controller determines the logical interaction between the device and
the computer
Solid-state disks – faster than hard disks, nonvolatile
Various technologies, Becoming more popular
29
Storage Hierarchy
Storage systems organized in hierarchy
Speed
Cost
Volatility
Caching – copying information into faster storage system;
main memory can be viewed as a cache for secondary storage.
Device Driver for each device controller to manage I/O
Provides uniform interface between controller and kernel
30
Storage-Device Hierarchy
31
Caching
Important principle, performed at many levels in a computer (in
hardware, operating system, software)
Information in use copied from slower to faster storage temporarily
Faster storage (cache) checked first to determine if information is
there
If it is, information used directly from the cache (fast)
If not, data copied to cache and used there
Cache smaller than storage being cached
Cache management important design problem
Cache size and replacement policy 32
Direct Memory Access Structure
Used for high-speed I/O devices able to transmit information at
close to memory speeds
Device controller transfers blocks of data from buffer storage
directly to main memory without CPU intervention
Only one interrupt is generated per block, rather than the one
interrupt per byte
33
How a Modern Computer Works
A von Neumann architecture
34
Memory Layout for Multiprogrammed System
Operating System Concepts – 9th Edition
1.35
Silberschatz, Galvin and Gagne ©2013
History of Operating Systems and
Important Technological
Advancements in a NutShell
36
History
1969: Bell labs introduce UNIX
1970: Intel introduces the first DRAM chip
1971: Floppy disk invented by IBM engineers, XEROX introduced the
first laser printer.
1973: Robert Betcalfe at Xerox, developed Ethernet, connecting multiple
computers and hardware.
1974: Personal computers got officially on the market.
1975: Microsoft got founded.
1977: Apple II was unveiled by Jobs and Wozniak. Machines were the
first ones that boasted color graphics.
1981: IBM releases the first personal computer: ACORN, with an Intel
chip, two floppy disks, and an available color monitor.
1983: the CD-ROM is out in the market. Microsoft introduces WORD.
1984: Apple launches Macintosh, a mouse-driven computer with a
graphical user interface, sold for $2,500.
37
History - continued
1985: Microsoft announces Windows, the first dot com domain name is
launched, and C++ is published!
1990: HTML is developed.
1996: Sergey Brin and Larry Page develop Google at Stanford.
1999: Wi-Fi becomes part of the computing language, as users begin
connecting without wires.
2001-2003: Apple introduces the Mac OS X, Microsoft unveiled Windows
XP, Apple releases iTunes, Blu-ray optical disk introduced.
2004: Mozilla’s Firefox 1 is introduced, Facebook is launched.
2005: Youtube is founded.
2006: Apple unveiled MacBook Pro: first Intel based, dual core mobile
computer, Amazon Web Services are launched, including Amazon
Elastic Cloud (EC2) and Amazon Simple Storage Service (S3). Amazon
made it possible for users to use the cloud to scale server capacity
quickly and efficiently. S3 was a cloud-based file hosting service that
charged users monthly for the amount of data they stored.
38
History - continued
2007: Apple released the first iPhone, Amazon released the Kindle,
Dropbox was founded.
2008: Apple releases the MacBook Air, the first ultra notebook that was a
thin and lightweight laptop with a high-capacity battery. A solid-state disk
was used for the first time in a mass-marketed computer.
2011: Google releases the Chromebook, a laptop that runs on Google
Chrome OS.
2012: Raspberry Pi, a credit-card-sized single-board computer is released,
weighing only 45 grams.
2014: The University of Michigan Micro Mote (M3), the smallest computer
in the world is created.
2015: Apple releases Apple Watch, Microsoft announced Windows 10.
2016: The first reprogrammable quantum computer is created.
2021: Windows 11 got released.
2022: First exascale supercomputer, world's fastest, Frontier, went online
at the Oak Ridge Leadership Computing
Facility (OLCF)
39
History - continued
2022: ChatGPT Released (natural language processing), “Osprey”
Quantum Computer Chip (433 QubitS)
2023: ChatGPT and AI apps run on GPT. GPT4 is trained on a much
more massive data set and is far more accurate and better at
understanding the intentions of the user’s prompts.
2024: The “democratization” of ChatGPT.
2024: Extended reality (ER) expands beyond entertainment: medicine,
automotive manufacturing industry, army … ER provides up-close
first-person view of complex and intricate processes in a safe
environment where mistakes can be easily remedied. ER
encompasses Augmented Reality, Mixed Reality, Virtual Reality.
40
History - continued
Trends between 2016 - now: 5G, Virtual and Augmented reality, Nonvolatile memory, Cyber-physical Systems, Data Science, Security,
Artificial Intelligence, Advanced Machine Learning, Network Function
Virtualization, Containers, Smart Devices, Datafication, Extended
Reality, Digital Trust, Blockchain,…
Check the list of Intel CPU microarchitectures over the years
Check the list of multi-core machines over the years….
Check the list of ARM microarchitectures over the years
Check the list of supercomputing units over the years.
41
Architectural Refresher
42
Architectural Refresher
View of a computer from an Operating System’s designer
perspective
Operating system is a layer of software that creates a virtual
machine
OS also manages the resources of this machine but this mostly involves
sharing policies so will be discussed later
These lectures will familiarize you with
The underlying machine
The extra hardware mechanisms needed for virtualization
43
Topics
The von Neumann architecture
CPU + memory
Hardware support for abstracting the basic machine
Modes, Exceptions, Traps and Interrupts
Input and Output
Network, storage and graphics
44
Conceptual Model
Addresses of
memory cells
CPU
+
*
/
Memory contents
0
1
2
3
4
5
6
7
8
9
45
"big byte array"
Operating System Perspective
A computer is a piece of hardware which runs the fetch-decodeexecute loop
Next slides: walk through a very simple computer to illustrate
Machine organization
What are the pieces and how they fit together
The basic fetch-decode-execute loop
How higher-level constructs are translated into machine instructions
At its core, the OS builds what looks like a more complex
machine on top of this basic hardware
46
Fetch-Decode-Execute
Computer as a large, general purpose calculator
want to program it for multiple functions
All von Neumann computers follow the same loop:
Fetch the next instruction from memory
Decode the instruction to figure out what to do
Execute the instruction
Store the result
Instructions are simple. Examples:
Increment the value of a memory cell by 1
Add the contents of memory cells X and Y and store in Z
Multiply contents of memory cells A and B and store in B
47
Instruction Encoding
How to represent instructions as numbers?
8 bits
operators
+: 1
-: 2
*: 3
/: 4
8 bits
8 bits
operands
48
8 bits
destination
Simple Fictitious Example Encoding
Add cell 28 to cell 63 and place result in cell 100:
8 bits
operator/
instruction
+: 1
-: 2
*: 3
/: 4
8 bits
8 bits
source operands
Cell 28
Cell 63
8 bits
destination
Cell 100
Instruction as a number in:
Decimal: 1:28:63:100
Binary: 00000001:00011100:00111111:01100100
Hexadecimal: 01:1C:3F:64
How many instructions can this encoding have?
49
Example Encoding (cont)
How many instructions can this encoding have?
8 bits, 2^8 combinations = 256 instructions
How much memory can this example instruction set support?
Assume each memory cell is a byte (8 bits) wide
Assume operands and destination come from the same memory
8 bits per source/dest = 2^8 combinations = 256 bytes
How many bytes did we use per instruction?
4 bytes per instruction
How could we get more memory without changing the encoding?
Why is this simple encoding not realistic?
50
The Program Counter
Q: Where is the “next instruction” held in the machine?
51
The Program Counter
Q: Where is the “next instruction” held in the machine?
Answer:
In a special memory cell in the CPU called the “program
counter" (the PC)
Special purpose memory in the CPU and devices are called registers
Naive fetch cycle: Increment the PC by the instruction length (4)
after each execute
Assumes all instructions are the same length
52
Conceptual Model
Memory
0 operator
1 operand 1
2 operand 2
3 destination
4
5
6
7
8
9
CPU
Arithmetic
Units
Program
Counter
+
*
/
4
53
Instruction 0
@ memory
address 0
Instruction 1
@ memory
address 4
Memory Indirection
Q: How do we access array elements efficiently if all we can do
is name a cell?
54
Memory Indirection
Q: How do we access array elements efficiently if all we can do
is name a cell?
Answer:
Modify the operand to allow for fetching an operand "through" a
memory location
E.g.: LOAD [5], 2 means fetch the contents of the cell whose address is
in cell 5 and put it into cell 2
So if cell 5 had the number 100, we would place the contents of cell 100
into cell 2
This is called indirection
Fetch the contents of the cell “pointed to” by the cell in the opcode
Steal an operand bit to signify if an indirection is desired
55
Conditionals and Looping
Instructions that modify the Program Counter
Conditional instructions
If the content of this cell is [positive, not zero, etc.] execute the
instruction or not
Branch Instructions
If the content of this cell is [zero, non zero, etc.], set the PC to this
location
jump is an unconditional branch
56
Example: While Loop
while (counter > 0) {
Variables to memory cells:
counter is cell 1
sum is cell 2
index is cell 3
Y[0]= cell 4, Y[1]=cell 5…
sum = sum + Y[counter];
counter–-;
};
Memory Assembler
cell address label
100
LOOP:
104
108
112
116
120
END:
Assembler
"mnemonic"
BNZ 1,END
English
// branch to address of END
// if cell 1 is 0.
ADD 2,[3],2 // Add cell 2 and the value
// of the cell pointed to by
// cell 3 then place the
// result in cell 2
DEC 3
// decrement cell 3 by 1
DEC 1
// decrement cell 1 by 1
JUMP LOOP
// start executing from the
// address of LOOP
<next code block>
57
Registers
Architecture rule: large memories are slow, small ones are fast
But everyone wants more memory!
Solution: Put small amount of memory in the CPU for faster operation
Most programs work on only small chunks of memory in a given time period (locality).
So, if we cache the contents of a small number of memory cells in the CPU memory, we
might be able to execute a number of instructions before having to access memory
Most CPUs have 16-32 “general purpose” registers
Source or destination registers look the “same”: operations are 100-1000 times faster when
operands are in registers compared to when they are in memory.
Operands and destination can be in:
Registers only (Sparc, PowerPC, Mips, RISC-V, Alpha)
Registers & 1 memory operand (x86) OR any combination of registers and memory (Vax)
Only memory operations possible in "register-only" machines are load from and store
to memory. Save instruction space too 58
Register Machine Model
Memory
CPU
Arithmetic Units
Logic Units
+,-,*,/
<,>,!=
Program Counter
8
register 0
24
register 1
100
register 2
18
59
0
1
2
3
4
5
6
7
8
9
Typical Instructions
Add the contents of register 2 and register 3 and place result in
register 5
ADD r2,r3,r5
Add 100 to the PC if register 2 is not zero
Relative branch
BNZ r2,100
Load the contents of memory location whose address is in
register 5 into register 6
LDI r5,r6
60
0
You can add this document to your study collection(s)
Sign in Available only to authorized usersYou can add this document to your saved list
Sign in Available only to authorized users(For complaints, use another form )