SlideShare a Scribd company logo
1 of 102
Principles of Operating Systems -
Lecture 1 1
ICS 143A - Principles of
Operating Systems
(Spring 2020)
Lecture 1 - Introduction and Overview
MWF 11:00- 11:50 a.m.
Prof. Nalini Venkatasubramanian
( nalini@uci.edu )
[lecture slides contains some content adapted from :
Silberschatz textbook authors, John Kubiatowicz (Berkeley)
Anderson textbook, John Ousterhout(Stanford), Prof. Ardalan
Sani, )
]
Principles of Operating Systems -
Lecture 1 2
ICS 143A Spring 2020 Staff
Instructor:
Prof. Nalini Venkatasubramanian (Venkat)
( nalini@uci.edu )
Teaching Assistants:
Biswadeep Maity (Deep) (maityb@uci.edu)
Saehanseul Yi (Hans) (saehansy@uci.edu)
Andrew Chio (achio@uci.edu)
Principles of Operating Systems -
Lecture 1 3
Course logistics and details
● Course Web page -
● http://www.ics.uci.edu/~ics143
● All new announcements and updates will be on class webpage
● Lectures – MWF 11:00 – 11:50, on zoom
● Zoom link: https://uci.zoom.us/j/568633190
● Discussions
● Tuesday 5pm - 6pm; 7pm- 8pm
● Zoom Link:
● 5 - 6 pm session: https://uci.zoom.us/j/556715006
● 7- 8 pm session: https://uci.zoom.us/j/563851913
Course logistics and details
● ICS 143 Textbook
● Operating System Concepts – 9th Edition, Silberschatz, Galvin and Gagne, Addison-Wesley
Inc (Eighth, Seventh,Sixth and Fifth editions, and Java Versions are fine ).
● Other Suggested Books
● Modern Operating Systems, by Tanenbaum
● Lubomir Bic, online book -- zybooks
● https://www.zybooks.com/catalog/operating-systems/
● Operating Systems: Principles and Practice, by T. Anderson and M. Dahlin
(second edition)
● Piazza for group discussions (https://piazza.com/uci/spring2020/cs143)
● Q/A, Student discussions, monitored by ICS143A staff
● Avoid duplicate posts, Use clear, descriptive titles
● Please be respectful to each other
4
Principles of Operating Systems -
Lecture 1 5
Course logistics and details
● Homeworks and Assignments
● 4 written homeworks in the quarter
● 1 programming assignment (knowledge of C, C++ or Java
required).
● Handed out at midterm; submit during Finals Week
● Multistep assignment – don’t start in last week of classes!!!
● Late homeworks will not be accepted.
● All submissions will be made using Gradescope for the course
● Tests
● Midterm - tentatively Wednesday, Week 6
● Detailed format and tools to be used -- TBD
● Final Exam - as per UCI course catalog
● June 9th (1:30 - 3:30 pm)
● Detailed format and tools to be used -- TBD
Principles of Operating Systems -
Lecture 1 6
ICS 143 Grading Policy
● Homeworks - 40% (10% each)
● Programming Assignment - 10%
● released Week 6
● Midterm - 20% of the final grade
● Tentatively Wed, Week 6 during lecture
● Final exam - 30% of the final grade
● Per UCI course catalog, Jun 9th (1:30 - 3:30 pm)
● 3 In-class micro-quizzes (not graded, except in case of borderline grades)
Final assignment of grades will be based on a curve.
Principles of Operating Systems -
Lecture 1 7
Lecture Schedule
● Week 1:
• Introduction to Operating Systems, Computer System
Structures, Operating System Structures
● Week 2 : Process Management
• Processes and Threads, CPU Scheduling
● Week 3: Process Management
• CPU Scheduling, Process Synchronization
● Week 4: Process Management
• Process Synchronization
● Week 5: Process Management
• Process Synchronization, Deadlocks
Principles of Operating Systems -
Lecture 1 8
Course Schedule
● Week 6 – Deadlocks, Storage Management
• Deadlocks, Midterm revision, exam
● Week 7 - Storage Management
• Memory Management, Paging, Segmentation
● Week 8 – Storage Management
• Virtual Memory
● Week 9 - FileSystems
• Virtual Memory, FileSystems Interface and Implementation
● Week 10 – I/O Subsystems
• Filesystems, I/O, course revision and summary.
Other Logistics
● Office Hours
● Prof. V - Tuesdays (11 am - 12 noon)
● TA office hours – Mon, Wed. Thurs (to be announced on
website)
● Slides
● Available as draft before lecture, minor modifications likely
● If there are missed lectures
● Alternatives will be arranged
Principles of Operating Systems -
Lecture 1 9
Principles of Operating Systems -
Lecture 1 10
Introduction
● What is an operating system?
● Operating Systems History
● Simple Batch Systems
● Multiprogrammed Batch Systems
● Time-sharing Systems
● Personal Computer Systems
● Parallel and Distributed Systems
● Real-time Systems
Principles of Operating Systems -
Lecture 1 11
What is an Operating System?
● An OS is a program that acts an intermediary
between the user of a computer and computer
hardware.
● Major cost of general purpose computing is
software.
● OS simplifies and manages the complexity of running
application programs efficiently.
Principles of Operating Systems -
Lecture 1 12
Computer System
Components
● Hardware
● Provides basic computing resources (CPU, memory, I/O devices).
● Operating System
● Controls and coordinates the use of hardware among application programs.
● Application Programs
● Solve computing problems of users (compilers, database systems, video games,
business programs such as banking software).
● Users
● People, machines, other computers
Principles of Operating Systems -
Lecture 1 13
Abstract View of System
System and Application Programs
Operating System
Computer
Hardware
User
1 User
2
User
3
User
n
compiler assembler Text editor Database
system
...
Principles of Operating Systems -
Lecture 1 14
Operating System Views
● Resource allocator
● to allocate resources (software and hardware) of the
computer system and manage them efficiently.
● Control program
● Controls execution of user programs and operation of I/O
devices.
● Kernel
● The program that executes forever (everything else is an
application with respect to the kernel).
Operating system roles
• Referee
• Resource allocation among users, applications
• Isolation of different users, applications from each other
• Communication between users, applications
• Illusionist
• Each application appears to have the entire machine to itself
• Infinite number of processors, (near) infinite amount of
memory, reliable storage, reliable network transport
• Glue
• Libraries, user interface widgets, …
• Reduces cost of developing software
15
Example: file systems
• Referee
• Prevent users from accessing each other’s files without
permission
• Illusionist
• Files can grow (nearly) arbitrarily large
• Files persist even when the machine crashes in the middle of a
save
• Glue
• Named directories, printf, …
16
Principles of Operating Systems -
Lecture 1 17
Goals of an Operating System
● Simplify the execution of user programs and
make solving user problems easier.
● Use computer hardware efficiently.
● Allow sharing of hardware and software resources.
● Make application software portable and versatile.
● Provide isolation, security and protection among
user programs.
● Improve overall system reliability
● error confinement, fault tolerance, reconfiguration.
Principles of Operating Systems -
Lecture 1 18
Why should I study Operating
Systems?
● Need to understand interaction between the hardware
and applications
● New applications, new hardware..
● Inherent aspect of society today
● Need to understand basic principles in the design of
computer systems
● efficient resource management, security, flexibility
● Increasing need for specialized operating systems
● e.g. embedded operating systems for devices - cell phones,
sensors and controllers
● real-time operating systems - aircraft control, multimedia
services
Computer System Architecture
(traditional)
Systems Today
Principles of Operating Systems -
Lecture 1 20
Irvine Sensorium
Hardware Complexity
Increases
Principles of Operating Systems -
Lecture 1 22
Moore’s Law: 2X
transistors/Chip Every 1.5 years
Moore’s
Law
From Berkeley OS course
From Hennessy and Patterson, Computer Architecture: A Quantitative
Approach, 4th edition, Sept. 15, 2006
Intel Multicore Chipsets
OS needs to keep pace with
hardware improvements
23
$/
Software Complexity Increases
Principles of Operating Systems -
Lecture 1 24
From MIT’s 6.033 course
People-to-Computer Ratio Over
Time
From David Culler (Berkeley)
Principles of Operating Systems -
Lecture 1 26
Operating System Spectrum
● Monitors and Small Kernels
● special purpose and embedded systems, real-time systems
● Batch and multiprogramming
● Timesharing
● workstations, servers, minicomputers, timeframes
● Transaction systems
● Personal Computing Systems
● Mobile Platforms, devices (of all sizes)
Principles of Operating Systems -
Lecture 1 27
Early Systems - Bare Machine
(1950s)
● Structure
● Large machines run from console
● Single user system
• Programmer/User as operator
● Paper tape or punched cards
● Early software
● Assemblers, compilers, linkers, loaders, device drivers, libraries of
common subroutines.
● Secure execution
● Inefficient use of expensive resources
● Low CPU utilization, high setup time.
From John Ousterhout slides
Hardware – expensive ; Human – cheap
Simple Batch Systems
(1960’s)
● Reduce setup time by batching jobs with similar requirements.
● Add a card reader, Hire an operator
● User is NOT the operator
● Automatic job sequencing
● Forms a rudimentary OS.
● Resident Monitor
● Holds initial control, control transfers to job and then back to monitor.
● Problem
● Need to distinguish job from job and data from program.
Principles of Operating Systems -
Lecture 1 28
From John Ousterhout slides
Principles of Operating Systems -
Lecture 1 29
Supervisor/Operator Control
● Secure monitor that controls job processing
● Special cards indicate what to do.
● User program prevented from performing I/O
● Separate user from computer
● User submits card deck
● cards put on tape
● tape processed by operator
● output written to tape
● tape printed on printer
● Problems
● Long turnaround time - up to 2 DAYS!!!
● Low CPU utilization
• I/O and CPU could not overlap; slow mechanical devices.
IBM 7094
From John Ousterhout slides
Principles of Operating Systems -
Lecture 1 30
Batch Systems - Issues
● Solutions to speed up I/O:
● Offline Processing
● load jobs into memory from tapes, card reading and line printing are done
offline.
● Spooling
● Use disk (random access device) as large storage for reading as many input
files as possible and storing output files until output devices are ready to
accept them.
● Allows overlap - I/O of one job with computation of another.
● Introduces notion of a job pool that allows OS choose next job to run so as
to increase CPU utilization.
Principles of Operating Systems -
Lecture 1 31
Speeding up I/O
Principles of Operating Systems -
Lecture 1 32
Batch Systems - I/O
completion
● How do we know that I/O is complete?
● Polling:
● Device sets a flag when it is busy.
● Program tests the flag in a loop waiting for completion of
I/O.
● Interrupts:
● On completion of I/O, device forces CPU to jump to a specific
instruction address that contains the interrupt service
routine.
● After the interrupt has been processed, CPU returns to code
it was executing prior to servicing the interrupt.
Principles of Operating Systems -
Lecture 1 33
Multiprogramming
● Use interrupts to run multiple programs
simultaneously
● When a program performs I/O, instead of polling, execute
another program till interrupt is received.
● Requires secure memory, I/O for each program.
● Requires intervention if program loops
indefinitely.
● Requires CPU scheduling to choose the next job
to run.
Principles of Operating Systems -
Lecture 1 34
Timesharing
● Programs queued for execution in FIFO order.
● Like multiprogramming, but timer device
interrupts after a quantum (timeslice).
● Interrupted program is returned to end of FIFO
● Next program is taken from head of FIFO
● Control card interpreter replaced by command
language interpreter.
Hardware – getting cheaper; Human – getting expensive
Principles of Operating Systems -
Lecture 1 35
Timesharing (cont.)
● Interactive (action/response)
● when OS finishes execution of one command, it seeks
the next control statement from user.
● File systems
● online filesystem is required for users to access data and
code.
● Virtual memory
● Job is swapped in and out of memory to disk.
Principles of Operating Systems -
Lecture 1 36
Personal Computing Systems
● Single user systems, portable.
● I/O devices - keyboards, mice, display screens, small
printers.
● Laptops and palmtops, Smart cards, Wireless devices.
● Single user systems may not need advanced CPU
utilization or protection features.
● Advantages:
● user convenience, responsiveness, ubiquitous
Hardware – cheap ; Human – expensive
Principles of Operating Systems -
Lecture 1 37
Parallel Systems
● Multiprocessor systems with more than one CPU
in close communication.
● Improved Throughput, economical, increased
reliability.
● Kinds:
• Vector and pipelined
• Symmetric and asymmetric multiprocessing
• Distributed memory vs. shared memory
● Programming models:
• Tightly coupled vs. loosely coupled ,message-based vs. shared
variable
Parallel Computing Systems
Principles of Operating Systems -
Lecture 1 38
Climate modeling,
earthquake
simulations, genome
analysis, protein
folding, nuclear fusion
research, …..
ILLIAC 2 (UIllinois)
Connection Machine (MIT)
IBM Blue Gene
Tianhe-1(China)
K-computer(Japan)
Principles of Operating Systems -
Lecture 1 39
Distributed Systems
● Distribute computation among many processors.
● Loosely coupled -
• no shared memory, various communication lines
● client/server architectures
● Advantages:
• resource sharing
• computation speed-up
• reliability
• communication - e.g. email
● Applications - digital libraries, digital multimedia
Hardware – very cheap ; Human – very expensive
Distributed Computing Systems
Principles of Operating Systems -
Lecture 1 40
Globus Grid Computing Toolkit Cloud Computing Offerings
PlanetLab Gnutella P2P Network
Principles of Operating Systems -
Lecture 1 41
Real-time systems
● Correct system function depends on timeliness
● Feedback/control loops
● Sensors and actuators
● Hard real-time systems -
● Failure if response time too long.
● Secondary storage is limited
● Soft real-time systems -
● Less accurate if response time is too long.
● Useful in applications such as multimedia, virtual reality.
A personal computer today
● Super AMOLED display
● Capacitive touchscreen
(multitouch)
● Audio (speaker, microphone)
● Vibration
● S pen
● 4G LTE
● NFC
● WiFi
● Bluetooth
● Infrared
● 64 GB internal storage (extended
by microSD)
● Adreno 330 GPU
● Hexagon DSP
● Multimedia processor
● 13 MP front camera
● 2 MP back camera
● Accelerometer
● Gyroscope
● Proximity sensor
● Compass
● Barometer
● Temperature sensor
● Humidity sensor
● Gesture Sensor
● GPS
42
interaction
A personal computer today
● Super AMOLED display
● Capacitive touchscreen
(multitouch)
● Audio (speaker, microphone)
● Vibration
● S pen
● 4G LTE
● NFC
● WiFi
● Bluetooth
● Infrared
● 64 GB internal storage (extended
by microSD)
● Adreno 330 GPU
● Hexagon DSP
● Multimedia processor
● 13 MP front camera
● 2 MP back camera
● Accelerometer
● Gyroscope
● Proximity sensor
● Compass
● Barometer
● Temperature sensor
● Humidity sensor
● Gesture Sensor
● GPS
43
sensing
A personal computer today
● Super AMOLED display
● Capacitive touchscreen
(multitouch)
● Audio (speaker, microphone)
● Vibration
● S pen
● 4G LTE
● NFC
● WiFi
● Bluetooth
● Infrared
● 64 GB internal storage (extended
by microSD)
● Adreno 330 GPU
● Hexagon DSP
● Multimedia processor
● 13 MP front camera
● 2 MP back camera
● Accelerometer
● Gyroscope
● Proximity sensor
● Compass
● Barometer
● Temperature sensor
● Humidity sensor
● Gesture Sensor
● GPS
44
connectivity
A personal computer today
● Super AMOLED display
● Capacitive touchscreen
(multitouch)
● Audio (speaker, microphone)
● Vibration
● S pen
● 4G LTE
● NFC
● WiFi
● Bluetooth
● Infrared
● 64 GB internal storage (extended
by microSD)
● Adreno 330 GPU
● Hexagon DSP
● Multimedia processor
● 13 MP front camera
● 2 MP back camera
● Accelerometer
● Gyroscope
● Proximity sensor
● Compass
● Barometer
● Temperature sensor
● Humidity sensor
● Gesture Sensor
● GPS
45
acceleration
Operating systems are
everywhere
46
Operating systems are
everywhere
47
Info-tainment!!
48
Principles of Operating Systems -
Lecture 1 49
Summary of lecture
● What is an operating system?
● Early Operating Systems
● Simple Batch Systems
● Multiprogrammed Batch Systems
● Time-sharing Systems
● Personal Computer Systems
● Parallel and Distributed Systems
● Real-time Systems
Computer System & OS Structures
• Computer System Organization
• Operational Flow and hardware protection
• System call and OS services
• Storage architecture
• OS organization
• OS tasks
• Virtual Machines
50
Computer System Organization
51
Fetch
Exec
R0
…
R31
F0
…
F30
PC
…
Data1
Data0
Inst237
Inst236
…
Inst5
Inst4
Inst3
Inst2
Inst1
Inst0
Addr 0
Addr 232-1
CPU execution
• Execution sequence:
• Fetch Instruction at PC
• Decode
• Execute (possibly using registers)
• Write results to registers/mem
• PC = Next Instruction(PC)
• Repeat
PC
PC
PC
PC
From Berkeley OS course
52
Computer System Organization
53
I/O devices
I/O devices
• I/O devices and the CPU execute concurrently.
• Each device controller is in charge of a particular
device type
• Each device controller has a local buffer. I/O is from the
device to local buffer of controller
• CPU moves data from/to main memory to/from the
local buffers
54
Interrupts
• Interrupt transfers control to the
interrupt service routine
• Interrupt Service Routine: Segments of
code that determine action to be taken for
interrupt.
• Determining the type of interrupt
• Polling: same interrupt handler called for
all interrupts, which then polls all devices
to figure out the reason for the interrupt
• Interrupt Vector Table: different interrupt
handlers will be executed for different
interrupts
55
Interrupt handling
• OS preserves the state of the CPU
• stores registers and the program counter (address of
interrupted instruction).
• What happens to a new interrupt when the CPU
is handling one interrupt?
• Incoming interrupts can be disabled while another interrupt is
being processed. In this case, incoming interrupts may be lost or
may be buffered until they can be delivered.
• Incoming interrupts can be masked (i.e., ignored) by software.
• Incoming interrupts are delivered, i.e., nested interrupts.
56
Direct Memory Access (DMA)
Memory
CPU
I/O devices
I/O instructions
57
• Typically used for I/O devices
with a lot of data to transfer (in
order to reduce load on CPU).
• Device controller transfers
blocks of data from buffer
storage directly to main
memory without CPU
intervention.
• Device controller interrupts
CPU on completion of I/O
• Only one interrupt is generated
per block, rather than one per
byte (or word).
Process Abstraction
58
Process Abstraction
• Process: an instance of a program, running
with limited rights
59
Process Abstraction and rights
• Process: an instance of a program, running
with limited rights
• Address space: set of rights of a process
• Memory that the process can access
• Other permissions the process has (e.g., which
system calls it can make, what files it can access)
60
Hardware Protection
• CPU Protection:
• Dual Mode Operation
• Timer interrupts
• Memory Protection
• I/O Protection
61
How to limit process rights?
62
Should a process be able to
execute any instructions?
63
Should a process be able to
execute any instructions?
● No
● Can alter system configuration
● Can access unauthorized memory
● Can access unauthorized I/O
● etc.
● How to prevent?
64
Dual-mode operation
• Provide hardware support to differentiate between at
least two modes of operation:
1. User mode -- execution done on behalf of a user.
2. Kernel mode (monitor/supervisor/system mode) --
execution done on behalf of operating system.
• “Privileged” instructions are only executable in the
kernel mode
• Executing privileged instructions in the user mode
“traps” into the kernel mode
●Trap is a software generated interrupt caused either by
an error or a user request
65
Dual-mode operation(cont.)
• Mode bit added to computer
hardware to indicate the current
mode: kernel(0) or user(1).
• When an interrupt or trap
occurs, hardware switches to
kernel mode.
User
Kernel
Set
user
mode
Interrupt/
fault
66
CPU Protection
• How to prevent a process from executing
indefinitely?
67
CPU Protection
• Timer - interrupts computer after specified period to
ensure that OS maintains control.
• Timer is decremented every clock tick.
• When timer reaches a value of 0, an interrupt occurs.
• Timer is commonly used to implement time
sharing.
• Timer is also used to compute the current time.
• Programming the timer can only be done in the
kernel since it requires privileged instructions.
68
How to isolate memory
access?
69
Process
Address
Space
Process address space
• Address space ⇒ the set of accessible
addresses + state associated with them:
• For a 32-bit processor there are 232 = 4 billion
addresses
• What happens when you read or write to an
address?
• Perhaps Nothing
• Perhaps acts like regular memory
• Perhaps ignores writes
• Perhaps causes I/O operation
• (Memory-mapped I/O)
• Perhaps causes exception (fault)
70
(code)
Virtual Address
71
Providing the Illusion of Separate Address Spaces
Proc 1
Virtual
Address
Space 1
Proc 2
Virtual
Address
Space 2
Code
Data
Heap
Stack
Code
Data
Heap
Stack
Data 2
Stack 1
Heap 1
kernel heap &
Stacks
Code 1
Stack 2
Data 1
Heap 2
Code 2
kernel code
kernel data
Translation Map 1 Translation Map 2
Physical Address Space 72
Address translation and memory
protection
Processor Translation
Physical
Memory
Data
Data
Valid
Invalid
Raise
Exception
Physical
address
73
Virtual
address
Memory Protection
• When a process is running, only memory in that process
address space must be accessible.
• When executing in kernel mode, the kernel has
unrestricted access to all memory.
• Must provide memory protection at least for the
interrupt vector and the interrupt service routines.
74
Memory Protection: base and limit
• To provide memory protection, add
two registers that determine the
range of legal addresses a program
may address.
• Base Register - holds smallest
legal physical memory address.
• Limit register - contains the size
of the range.
• Memory outside the defined range
is protected.
• Sometimes called Base and
Bounds method
0
300040
420940
1024000
300040
120900
Base register
Limit register
75
Hardware Address Protection
The load instructions for the base and limit
registers are privileged instructions.
76
Virtual Address translation using the
Base and Bounds method
77
The load instructions for the base and limit
registers are privileged instructions.
I/O Protection
• All I/O instructions are privileged instructions.
• Must ensure that a user program could never gain
control of the computer in kernel mode, e.g., a user
program must not be able to store a new address
in the interrupt vector.
78
Question
• Given the I/O instructions are privileged, how do
users perform I/O?
79
Question
• Given the I/O instructions are privileged, how do
users perform I/O?
• Via system calls - the method used by a process to
request action by the operating system.
80
System Calls
• User code can issue a syscall, which causes a trap
• Kernel handles the syscall
81
System Calls
• Interface between applications
and the OS.
• Application uses an
assembly instruction to trap into
the kernel
• Some higher level languages
provide wrappers for system
calls (e.g., C)
• System calls pass parameters
between an and OS via registers
or memory, memory tables or
stack.
• Linux has about 300 system
calls
• read(), write(), open(), close(),
fork(), exec(), ioctl(),…..
82
System services or system
programs
• Convenient environment for program development
and execution.
• Command Interpreter (i.e., shell) - parses/executes other
system programs
• Window management
• System libraries, e.g., libc
83
Command Interpreter System
• Commands that are given to the operating system
via command statements that execute
• Process creation and deletion, I/O handling, secondary
storage management, main memory Management, file
system access, protection, networking, etc.
• Obtains the next command and executes it.
• Programs that read and interpret control
statements also called -
• Command-line interpreter, shell (in UNIX)
84
Storage Structure
• Main memory - only large storage media that the
CPU can access directly.
• Secondary storage - has large nonvolatile storage
capacity.
• Magnetic disks - rigid metal or glass platters covered with
magnetic recording material.
• Disk surface is logically divided into tracks, subdivided into
sectors.
• Disk controller determines logical interaction between device
and computer.
85
Storage Hierarchy
• Storage systems are organized in a hierarchy
based on
• Speed
• Cost
• Volatility
• Caching - process of copying information into
faster storage system; main memory can be
viewed as fast cache for secondary storage.
86
Storage Device Hierarchy
87
OS Task: Process Management
• Process - fundamental concept in OS
• Process is an instance of a program in execution.
• Process needs resources - CPU time, memory, files/data
and I/O devices.
• OS is responsible for the following process
management activities.
• Process creation and deletion
• Process suspension and resumption
• Process synchronization and interprocess communication
• Process interactions - deadlock detection, avoidance and
correction
88
OS Task: Memory Management
• Main Memory is an array of addressable words or
bytes that is quickly accessible.
• Main Memory is volatile.
• OS is responsible for:
• Allocate and deallocate memory to processes.
• Managing multiple processes within memory - keep track of which
parts of memory are used by which processes. Manage the
sharing of memory between processes.
• Determining which processes to load when memory becomes
available.
89
OS Task: Secondary Storage and I/O
Management
• Since primary storage (i.e., main memory) is
expensive and volatile, secondary storage is
required for backup.
• Disk is the primary form of secondary storage.
• OS performs storage allocation, free-space management,
etc. and disk scheduling.
• I/O system in the OS consists of
• Device driver interface that abstracts device details
• Drivers for specific hardware devices
90
OS Task: File System Management
• File is a collection of related information -
represents programs and data.
• OS is responsible for
• File creation and deletion
• Directory creation and deletion
• Supporting primitives for file/directory manipulation.
• Mapping files to disks (secondary storage).
• Backup files on archival media (tapes).
91
OS Task: Protection and Security
• Protection mechanisms control access of processes to user
and system resources.
• Protection mechanisms must:
• Distinguish between authorized and unauthorized use.
• Specify access controls to be imposed on use.
• Provide mechanisms for enforcement of access control.
• Security mechanisms provide trust in system and privacy
• authentication, certification, encryption etc.
92
Operating Systems: How are they
organized?
• Simple
• Only one or two levels of code
• Layered
• Lower levels independent of upper levels
• Modular
• Core kernel with Dynamically loadable modules
• Microkernel
• OS built from many user-level processes
93
OS Structure - Simple Approach
• MS-DOS - provides a lot of functionality in little
space.
• Not divided into modules, Interfaces and levels of
functionality are not well separated
94
Original UNIX System Structure
• Limited structuring, has 2 separable parts
• Systems programs
• Kernel
• everything below system call interface and above physical hardware.
• Filesystem, CPU scheduling, memory management
95
Layered OS Structure
• OS divided into number of
layers - bottom layer is
hardware, highest layer is
the user interface.
• Each layer uses functions
and services of only lower-
level layers.
• THE Operating System and
Linux Kernel has successive
layers of abstraction.
96
Monolithic vs. Microkernel OS
• Monolithic OSes have large kernels with a lot of components
• Linux, Windows, Mac
• Microkernels moves as much from the kernel into “user” space
• Small core OS components running at kernel level
• OS Services built from many independent user-level processes
• Communication between modules with message passing
• Benefits:
• Easier to extend a microkernel
• Easier to port OS to new architectures
• More reliable and more secure (less code is running in kernel mode)
• Fault Isolation (parts of kernel protected from other par
• Detriments:
• Performance overhead severe for naïve implementation
97
A microkernel OS
98
Slide adapted from http://web.cecs.pdx.edu/~walpole/class/cs533/fall2015/home.html
Virtual Machines
99
Hardware
OS
Application
Physical Machine
Virtual Machines
100
Hardware
Virtual Machine Monitor (VMM) (aka Hypervisor)
OS
Application
OS
Application
Virtual Machine 1
OS
Application
Virtual Machine 2 Virtual Machine 3
Virtual Machines
101
• Use cases
●Resource configuration
●Running multiple OSes, either the same or different
OSes
●Run existing OS binaries on different architecture
Summary of Lecture set 1
• What is an operating system?
• Operating systems history
• Computer system and operating system structure
102

More Related Content

Similar to oslectureset1spr20.pptx

Similar to oslectureset1spr20.pptx (20)

9781285096551_PPT_ch01.pptx
9781285096551_PPT_ch01.pptx9781285096551_PPT_ch01.pptx
9781285096551_PPT_ch01.pptx
 
os unit 1 (2).pptx. introduction to operating systems
os unit 1 (2).pptx. introduction to operating systemsos unit 1 (2).pptx. introduction to operating systems
os unit 1 (2).pptx. introduction to operating systems
 
OS introduction.pptx
OS introduction.pptxOS introduction.pptx
OS introduction.pptx
 
OS-01.ppt
OS-01.pptOS-01.ppt
OS-01.ppt
 
OPERATING SYSTEM
OPERATING SYSTEMOPERATING SYSTEM
OPERATING SYSTEM
 
1 Introduction to OS.ppt
1 Introduction to OS.ppt1 Introduction to OS.ppt
1 Introduction to OS.ppt
 
Operating System concepts
Operating System conceptsOperating System concepts
Operating System concepts
 
Operating System.pdf
Operating System.pdfOperating System.pdf
Operating System.pdf
 
EMBEDDED OS
EMBEDDED OSEMBEDDED OS
EMBEDDED OS
 
OPERATING SYSTEMS - INTRODUCTION
OPERATING SYSTEMS - INTRODUCTIONOPERATING SYSTEMS - INTRODUCTION
OPERATING SYSTEMS - INTRODUCTION
 
Operating System
Operating SystemOperating System
Operating System
 
Unit 2.pptx
Unit 2.pptxUnit 2.pptx
Unit 2.pptx
 
Unit 2.pptx
Unit 2.pptxUnit 2.pptx
Unit 2.pptx
 
Operating System Overview.pdf
Operating System Overview.pdfOperating System Overview.pdf
Operating System Overview.pdf
 
Kernel security Concepts
Kernel security ConceptsKernel security Concepts
Kernel security Concepts
 
Operating System Introduction - Definition, Working, Components
Operating System Introduction - Definition, Working, ComponentsOperating System Introduction - Definition, Working, Components
Operating System Introduction - Definition, Working, Components
 
Os concepts
Os conceptsOs concepts
Os concepts
 
os unit 1.pdf
os unit 1.pdfos unit 1.pdf
os unit 1.pdf
 
Operating System / System Operasi
Operating System / System Operasi                   Operating System / System Operasi
Operating System / System Operasi
 
ayq.ppt
ayq.pptayq.ppt
ayq.ppt
 

Recently uploaded

Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
EADTU
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
CaitlinCummins3
 

Recently uploaded (20)

Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 

oslectureset1spr20.pptx

  • 1. Principles of Operating Systems - Lecture 1 1 ICS 143A - Principles of Operating Systems (Spring 2020) Lecture 1 - Introduction and Overview MWF 11:00- 11:50 a.m. Prof. Nalini Venkatasubramanian ( nalini@uci.edu ) [lecture slides contains some content adapted from : Silberschatz textbook authors, John Kubiatowicz (Berkeley) Anderson textbook, John Ousterhout(Stanford), Prof. Ardalan Sani, ) ]
  • 2. Principles of Operating Systems - Lecture 1 2 ICS 143A Spring 2020 Staff Instructor: Prof. Nalini Venkatasubramanian (Venkat) ( nalini@uci.edu ) Teaching Assistants: Biswadeep Maity (Deep) (maityb@uci.edu) Saehanseul Yi (Hans) (saehansy@uci.edu) Andrew Chio (achio@uci.edu)
  • 3. Principles of Operating Systems - Lecture 1 3 Course logistics and details ● Course Web page - ● http://www.ics.uci.edu/~ics143 ● All new announcements and updates will be on class webpage ● Lectures – MWF 11:00 – 11:50, on zoom ● Zoom link: https://uci.zoom.us/j/568633190 ● Discussions ● Tuesday 5pm - 6pm; 7pm- 8pm ● Zoom Link: ● 5 - 6 pm session: https://uci.zoom.us/j/556715006 ● 7- 8 pm session: https://uci.zoom.us/j/563851913
  • 4. Course logistics and details ● ICS 143 Textbook ● Operating System Concepts – 9th Edition, Silberschatz, Galvin and Gagne, Addison-Wesley Inc (Eighth, Seventh,Sixth and Fifth editions, and Java Versions are fine ). ● Other Suggested Books ● Modern Operating Systems, by Tanenbaum ● Lubomir Bic, online book -- zybooks ● https://www.zybooks.com/catalog/operating-systems/ ● Operating Systems: Principles and Practice, by T. Anderson and M. Dahlin (second edition) ● Piazza for group discussions (https://piazza.com/uci/spring2020/cs143) ● Q/A, Student discussions, monitored by ICS143A staff ● Avoid duplicate posts, Use clear, descriptive titles ● Please be respectful to each other 4
  • 5. Principles of Operating Systems - Lecture 1 5 Course logistics and details ● Homeworks and Assignments ● 4 written homeworks in the quarter ● 1 programming assignment (knowledge of C, C++ or Java required). ● Handed out at midterm; submit during Finals Week ● Multistep assignment – don’t start in last week of classes!!! ● Late homeworks will not be accepted. ● All submissions will be made using Gradescope for the course ● Tests ● Midterm - tentatively Wednesday, Week 6 ● Detailed format and tools to be used -- TBD ● Final Exam - as per UCI course catalog ● June 9th (1:30 - 3:30 pm) ● Detailed format and tools to be used -- TBD
  • 6. Principles of Operating Systems - Lecture 1 6 ICS 143 Grading Policy ● Homeworks - 40% (10% each) ● Programming Assignment - 10% ● released Week 6 ● Midterm - 20% of the final grade ● Tentatively Wed, Week 6 during lecture ● Final exam - 30% of the final grade ● Per UCI course catalog, Jun 9th (1:30 - 3:30 pm) ● 3 In-class micro-quizzes (not graded, except in case of borderline grades) Final assignment of grades will be based on a curve.
  • 7. Principles of Operating Systems - Lecture 1 7 Lecture Schedule ● Week 1: • Introduction to Operating Systems, Computer System Structures, Operating System Structures ● Week 2 : Process Management • Processes and Threads, CPU Scheduling ● Week 3: Process Management • CPU Scheduling, Process Synchronization ● Week 4: Process Management • Process Synchronization ● Week 5: Process Management • Process Synchronization, Deadlocks
  • 8. Principles of Operating Systems - Lecture 1 8 Course Schedule ● Week 6 – Deadlocks, Storage Management • Deadlocks, Midterm revision, exam ● Week 7 - Storage Management • Memory Management, Paging, Segmentation ● Week 8 – Storage Management • Virtual Memory ● Week 9 - FileSystems • Virtual Memory, FileSystems Interface and Implementation ● Week 10 – I/O Subsystems • Filesystems, I/O, course revision and summary.
  • 9. Other Logistics ● Office Hours ● Prof. V - Tuesdays (11 am - 12 noon) ● TA office hours – Mon, Wed. Thurs (to be announced on website) ● Slides ● Available as draft before lecture, minor modifications likely ● If there are missed lectures ● Alternatives will be arranged Principles of Operating Systems - Lecture 1 9
  • 10. Principles of Operating Systems - Lecture 1 10 Introduction ● What is an operating system? ● Operating Systems History ● Simple Batch Systems ● Multiprogrammed Batch Systems ● Time-sharing Systems ● Personal Computer Systems ● Parallel and Distributed Systems ● Real-time Systems
  • 11. Principles of Operating Systems - Lecture 1 11 What is an Operating System? ● An OS is a program that acts an intermediary between the user of a computer and computer hardware. ● Major cost of general purpose computing is software. ● OS simplifies and manages the complexity of running application programs efficiently.
  • 12. Principles of Operating Systems - Lecture 1 12 Computer System Components ● Hardware ● Provides basic computing resources (CPU, memory, I/O devices). ● Operating System ● Controls and coordinates the use of hardware among application programs. ● Application Programs ● Solve computing problems of users (compilers, database systems, video games, business programs such as banking software). ● Users ● People, machines, other computers
  • 13. Principles of Operating Systems - Lecture 1 13 Abstract View of System System and Application Programs Operating System Computer Hardware User 1 User 2 User 3 User n compiler assembler Text editor Database system ...
  • 14. Principles of Operating Systems - Lecture 1 14 Operating System Views ● Resource allocator ● to allocate resources (software and hardware) of the computer system and manage them efficiently. ● Control program ● Controls execution of user programs and operation of I/O devices. ● Kernel ● The program that executes forever (everything else is an application with respect to the kernel).
  • 15. Operating system roles • Referee • Resource allocation among users, applications • Isolation of different users, applications from each other • Communication between users, applications • Illusionist • Each application appears to have the entire machine to itself • Infinite number of processors, (near) infinite amount of memory, reliable storage, reliable network transport • Glue • Libraries, user interface widgets, … • Reduces cost of developing software 15
  • 16. Example: file systems • Referee • Prevent users from accessing each other’s files without permission • Illusionist • Files can grow (nearly) arbitrarily large • Files persist even when the machine crashes in the middle of a save • Glue • Named directories, printf, … 16
  • 17. Principles of Operating Systems - Lecture 1 17 Goals of an Operating System ● Simplify the execution of user programs and make solving user problems easier. ● Use computer hardware efficiently. ● Allow sharing of hardware and software resources. ● Make application software portable and versatile. ● Provide isolation, security and protection among user programs. ● Improve overall system reliability ● error confinement, fault tolerance, reconfiguration.
  • 18. Principles of Operating Systems - Lecture 1 18 Why should I study Operating Systems? ● Need to understand interaction between the hardware and applications ● New applications, new hardware.. ● Inherent aspect of society today ● Need to understand basic principles in the design of computer systems ● efficient resource management, security, flexibility ● Increasing need for specialized operating systems ● e.g. embedded operating systems for devices - cell phones, sensors and controllers ● real-time operating systems - aircraft control, multimedia services
  • 20. Systems Today Principles of Operating Systems - Lecture 1 20
  • 22. Hardware Complexity Increases Principles of Operating Systems - Lecture 1 22 Moore’s Law: 2X transistors/Chip Every 1.5 years Moore’s Law From Berkeley OS course From Hennessy and Patterson, Computer Architecture: A Quantitative Approach, 4th edition, Sept. 15, 2006 Intel Multicore Chipsets
  • 23. OS needs to keep pace with hardware improvements 23 $/
  • 24. Software Complexity Increases Principles of Operating Systems - Lecture 1 24 From MIT’s 6.033 course
  • 25. People-to-Computer Ratio Over Time From David Culler (Berkeley)
  • 26. Principles of Operating Systems - Lecture 1 26 Operating System Spectrum ● Monitors and Small Kernels ● special purpose and embedded systems, real-time systems ● Batch and multiprogramming ● Timesharing ● workstations, servers, minicomputers, timeframes ● Transaction systems ● Personal Computing Systems ● Mobile Platforms, devices (of all sizes)
  • 27. Principles of Operating Systems - Lecture 1 27 Early Systems - Bare Machine (1950s) ● Structure ● Large machines run from console ● Single user system • Programmer/User as operator ● Paper tape or punched cards ● Early software ● Assemblers, compilers, linkers, loaders, device drivers, libraries of common subroutines. ● Secure execution ● Inefficient use of expensive resources ● Low CPU utilization, high setup time. From John Ousterhout slides Hardware – expensive ; Human – cheap
  • 28. Simple Batch Systems (1960’s) ● Reduce setup time by batching jobs with similar requirements. ● Add a card reader, Hire an operator ● User is NOT the operator ● Automatic job sequencing ● Forms a rudimentary OS. ● Resident Monitor ● Holds initial control, control transfers to job and then back to monitor. ● Problem ● Need to distinguish job from job and data from program. Principles of Operating Systems - Lecture 1 28 From John Ousterhout slides
  • 29. Principles of Operating Systems - Lecture 1 29 Supervisor/Operator Control ● Secure monitor that controls job processing ● Special cards indicate what to do. ● User program prevented from performing I/O ● Separate user from computer ● User submits card deck ● cards put on tape ● tape processed by operator ● output written to tape ● tape printed on printer ● Problems ● Long turnaround time - up to 2 DAYS!!! ● Low CPU utilization • I/O and CPU could not overlap; slow mechanical devices. IBM 7094 From John Ousterhout slides
  • 30. Principles of Operating Systems - Lecture 1 30 Batch Systems - Issues ● Solutions to speed up I/O: ● Offline Processing ● load jobs into memory from tapes, card reading and line printing are done offline. ● Spooling ● Use disk (random access device) as large storage for reading as many input files as possible and storing output files until output devices are ready to accept them. ● Allows overlap - I/O of one job with computation of another. ● Introduces notion of a job pool that allows OS choose next job to run so as to increase CPU utilization.
  • 31. Principles of Operating Systems - Lecture 1 31 Speeding up I/O
  • 32. Principles of Operating Systems - Lecture 1 32 Batch Systems - I/O completion ● How do we know that I/O is complete? ● Polling: ● Device sets a flag when it is busy. ● Program tests the flag in a loop waiting for completion of I/O. ● Interrupts: ● On completion of I/O, device forces CPU to jump to a specific instruction address that contains the interrupt service routine. ● After the interrupt has been processed, CPU returns to code it was executing prior to servicing the interrupt.
  • 33. Principles of Operating Systems - Lecture 1 33 Multiprogramming ● Use interrupts to run multiple programs simultaneously ● When a program performs I/O, instead of polling, execute another program till interrupt is received. ● Requires secure memory, I/O for each program. ● Requires intervention if program loops indefinitely. ● Requires CPU scheduling to choose the next job to run.
  • 34. Principles of Operating Systems - Lecture 1 34 Timesharing ● Programs queued for execution in FIFO order. ● Like multiprogramming, but timer device interrupts after a quantum (timeslice). ● Interrupted program is returned to end of FIFO ● Next program is taken from head of FIFO ● Control card interpreter replaced by command language interpreter. Hardware – getting cheaper; Human – getting expensive
  • 35. Principles of Operating Systems - Lecture 1 35 Timesharing (cont.) ● Interactive (action/response) ● when OS finishes execution of one command, it seeks the next control statement from user. ● File systems ● online filesystem is required for users to access data and code. ● Virtual memory ● Job is swapped in and out of memory to disk.
  • 36. Principles of Operating Systems - Lecture 1 36 Personal Computing Systems ● Single user systems, portable. ● I/O devices - keyboards, mice, display screens, small printers. ● Laptops and palmtops, Smart cards, Wireless devices. ● Single user systems may not need advanced CPU utilization or protection features. ● Advantages: ● user convenience, responsiveness, ubiquitous Hardware – cheap ; Human – expensive
  • 37. Principles of Operating Systems - Lecture 1 37 Parallel Systems ● Multiprocessor systems with more than one CPU in close communication. ● Improved Throughput, economical, increased reliability. ● Kinds: • Vector and pipelined • Symmetric and asymmetric multiprocessing • Distributed memory vs. shared memory ● Programming models: • Tightly coupled vs. loosely coupled ,message-based vs. shared variable
  • 38. Parallel Computing Systems Principles of Operating Systems - Lecture 1 38 Climate modeling, earthquake simulations, genome analysis, protein folding, nuclear fusion research, ….. ILLIAC 2 (UIllinois) Connection Machine (MIT) IBM Blue Gene Tianhe-1(China) K-computer(Japan)
  • 39. Principles of Operating Systems - Lecture 1 39 Distributed Systems ● Distribute computation among many processors. ● Loosely coupled - • no shared memory, various communication lines ● client/server architectures ● Advantages: • resource sharing • computation speed-up • reliability • communication - e.g. email ● Applications - digital libraries, digital multimedia Hardware – very cheap ; Human – very expensive
  • 40. Distributed Computing Systems Principles of Operating Systems - Lecture 1 40 Globus Grid Computing Toolkit Cloud Computing Offerings PlanetLab Gnutella P2P Network
  • 41. Principles of Operating Systems - Lecture 1 41 Real-time systems ● Correct system function depends on timeliness ● Feedback/control loops ● Sensors and actuators ● Hard real-time systems - ● Failure if response time too long. ● Secondary storage is limited ● Soft real-time systems - ● Less accurate if response time is too long. ● Useful in applications such as multimedia, virtual reality.
  • 42. A personal computer today ● Super AMOLED display ● Capacitive touchscreen (multitouch) ● Audio (speaker, microphone) ● Vibration ● S pen ● 4G LTE ● NFC ● WiFi ● Bluetooth ● Infrared ● 64 GB internal storage (extended by microSD) ● Adreno 330 GPU ● Hexagon DSP ● Multimedia processor ● 13 MP front camera ● 2 MP back camera ● Accelerometer ● Gyroscope ● Proximity sensor ● Compass ● Barometer ● Temperature sensor ● Humidity sensor ● Gesture Sensor ● GPS 42 interaction
  • 43. A personal computer today ● Super AMOLED display ● Capacitive touchscreen (multitouch) ● Audio (speaker, microphone) ● Vibration ● S pen ● 4G LTE ● NFC ● WiFi ● Bluetooth ● Infrared ● 64 GB internal storage (extended by microSD) ● Adreno 330 GPU ● Hexagon DSP ● Multimedia processor ● 13 MP front camera ● 2 MP back camera ● Accelerometer ● Gyroscope ● Proximity sensor ● Compass ● Barometer ● Temperature sensor ● Humidity sensor ● Gesture Sensor ● GPS 43 sensing
  • 44. A personal computer today ● Super AMOLED display ● Capacitive touchscreen (multitouch) ● Audio (speaker, microphone) ● Vibration ● S pen ● 4G LTE ● NFC ● WiFi ● Bluetooth ● Infrared ● 64 GB internal storage (extended by microSD) ● Adreno 330 GPU ● Hexagon DSP ● Multimedia processor ● 13 MP front camera ● 2 MP back camera ● Accelerometer ● Gyroscope ● Proximity sensor ● Compass ● Barometer ● Temperature sensor ● Humidity sensor ● Gesture Sensor ● GPS 44 connectivity
  • 45. A personal computer today ● Super AMOLED display ● Capacitive touchscreen (multitouch) ● Audio (speaker, microphone) ● Vibration ● S pen ● 4G LTE ● NFC ● WiFi ● Bluetooth ● Infrared ● 64 GB internal storage (extended by microSD) ● Adreno 330 GPU ● Hexagon DSP ● Multimedia processor ● 13 MP front camera ● 2 MP back camera ● Accelerometer ● Gyroscope ● Proximity sensor ● Compass ● Barometer ● Temperature sensor ● Humidity sensor ● Gesture Sensor ● GPS 45 acceleration
  • 49. Principles of Operating Systems - Lecture 1 49 Summary of lecture ● What is an operating system? ● Early Operating Systems ● Simple Batch Systems ● Multiprogrammed Batch Systems ● Time-sharing Systems ● Personal Computer Systems ● Parallel and Distributed Systems ● Real-time Systems
  • 50. Computer System & OS Structures • Computer System Organization • Operational Flow and hardware protection • System call and OS services • Storage architecture • OS organization • OS tasks • Virtual Machines 50
  • 52. Fetch Exec R0 … R31 F0 … F30 PC … Data1 Data0 Inst237 Inst236 … Inst5 Inst4 Inst3 Inst2 Inst1 Inst0 Addr 0 Addr 232-1 CPU execution • Execution sequence: • Fetch Instruction at PC • Decode • Execute (possibly using registers) • Write results to registers/mem • PC = Next Instruction(PC) • Repeat PC PC PC PC From Berkeley OS course 52
  • 54. I/O devices • I/O devices and the CPU execute concurrently. • Each device controller is in charge of a particular device type • Each device controller has a local buffer. I/O is from the device to local buffer of controller • CPU moves data from/to main memory to/from the local buffers 54
  • 55. Interrupts • Interrupt transfers control to the interrupt service routine • Interrupt Service Routine: Segments of code that determine action to be taken for interrupt. • Determining the type of interrupt • Polling: same interrupt handler called for all interrupts, which then polls all devices to figure out the reason for the interrupt • Interrupt Vector Table: different interrupt handlers will be executed for different interrupts 55
  • 56. Interrupt handling • OS preserves the state of the CPU • stores registers and the program counter (address of interrupted instruction). • What happens to a new interrupt when the CPU is handling one interrupt? • Incoming interrupts can be disabled while another interrupt is being processed. In this case, incoming interrupts may be lost or may be buffered until they can be delivered. • Incoming interrupts can be masked (i.e., ignored) by software. • Incoming interrupts are delivered, i.e., nested interrupts. 56
  • 57. Direct Memory Access (DMA) Memory CPU I/O devices I/O instructions 57 • Typically used for I/O devices with a lot of data to transfer (in order to reduce load on CPU). • Device controller transfers blocks of data from buffer storage directly to main memory without CPU intervention. • Device controller interrupts CPU on completion of I/O • Only one interrupt is generated per block, rather than one per byte (or word).
  • 59. Process Abstraction • Process: an instance of a program, running with limited rights 59
  • 60. Process Abstraction and rights • Process: an instance of a program, running with limited rights • Address space: set of rights of a process • Memory that the process can access • Other permissions the process has (e.g., which system calls it can make, what files it can access) 60
  • 61. Hardware Protection • CPU Protection: • Dual Mode Operation • Timer interrupts • Memory Protection • I/O Protection 61
  • 62. How to limit process rights? 62
  • 63. Should a process be able to execute any instructions? 63
  • 64. Should a process be able to execute any instructions? ● No ● Can alter system configuration ● Can access unauthorized memory ● Can access unauthorized I/O ● etc. ● How to prevent? 64
  • 65. Dual-mode operation • Provide hardware support to differentiate between at least two modes of operation: 1. User mode -- execution done on behalf of a user. 2. Kernel mode (monitor/supervisor/system mode) -- execution done on behalf of operating system. • “Privileged” instructions are only executable in the kernel mode • Executing privileged instructions in the user mode “traps” into the kernel mode ●Trap is a software generated interrupt caused either by an error or a user request 65
  • 66. Dual-mode operation(cont.) • Mode bit added to computer hardware to indicate the current mode: kernel(0) or user(1). • When an interrupt or trap occurs, hardware switches to kernel mode. User Kernel Set user mode Interrupt/ fault 66
  • 67. CPU Protection • How to prevent a process from executing indefinitely? 67
  • 68. CPU Protection • Timer - interrupts computer after specified period to ensure that OS maintains control. • Timer is decremented every clock tick. • When timer reaches a value of 0, an interrupt occurs. • Timer is commonly used to implement time sharing. • Timer is also used to compute the current time. • Programming the timer can only be done in the kernel since it requires privileged instructions. 68
  • 69. How to isolate memory access? 69
  • 70. Process Address Space Process address space • Address space ⇒ the set of accessible addresses + state associated with them: • For a 32-bit processor there are 232 = 4 billion addresses • What happens when you read or write to an address? • Perhaps Nothing • Perhaps acts like regular memory • Perhaps ignores writes • Perhaps causes I/O operation • (Memory-mapped I/O) • Perhaps causes exception (fault) 70 (code)
  • 72. Providing the Illusion of Separate Address Spaces Proc 1 Virtual Address Space 1 Proc 2 Virtual Address Space 2 Code Data Heap Stack Code Data Heap Stack Data 2 Stack 1 Heap 1 kernel heap & Stacks Code 1 Stack 2 Data 1 Heap 2 Code 2 kernel code kernel data Translation Map 1 Translation Map 2 Physical Address Space 72
  • 73. Address translation and memory protection Processor Translation Physical Memory Data Data Valid Invalid Raise Exception Physical address 73 Virtual address
  • 74. Memory Protection • When a process is running, only memory in that process address space must be accessible. • When executing in kernel mode, the kernel has unrestricted access to all memory. • Must provide memory protection at least for the interrupt vector and the interrupt service routines. 74
  • 75. Memory Protection: base and limit • To provide memory protection, add two registers that determine the range of legal addresses a program may address. • Base Register - holds smallest legal physical memory address. • Limit register - contains the size of the range. • Memory outside the defined range is protected. • Sometimes called Base and Bounds method 0 300040 420940 1024000 300040 120900 Base register Limit register 75
  • 76. Hardware Address Protection The load instructions for the base and limit registers are privileged instructions. 76
  • 77. Virtual Address translation using the Base and Bounds method 77 The load instructions for the base and limit registers are privileged instructions.
  • 78. I/O Protection • All I/O instructions are privileged instructions. • Must ensure that a user program could never gain control of the computer in kernel mode, e.g., a user program must not be able to store a new address in the interrupt vector. 78
  • 79. Question • Given the I/O instructions are privileged, how do users perform I/O? 79
  • 80. Question • Given the I/O instructions are privileged, how do users perform I/O? • Via system calls - the method used by a process to request action by the operating system. 80
  • 81. System Calls • User code can issue a syscall, which causes a trap • Kernel handles the syscall 81
  • 82. System Calls • Interface between applications and the OS. • Application uses an assembly instruction to trap into the kernel • Some higher level languages provide wrappers for system calls (e.g., C) • System calls pass parameters between an and OS via registers or memory, memory tables or stack. • Linux has about 300 system calls • read(), write(), open(), close(), fork(), exec(), ioctl(),….. 82
  • 83. System services or system programs • Convenient environment for program development and execution. • Command Interpreter (i.e., shell) - parses/executes other system programs • Window management • System libraries, e.g., libc 83
  • 84. Command Interpreter System • Commands that are given to the operating system via command statements that execute • Process creation and deletion, I/O handling, secondary storage management, main memory Management, file system access, protection, networking, etc. • Obtains the next command and executes it. • Programs that read and interpret control statements also called - • Command-line interpreter, shell (in UNIX) 84
  • 85. Storage Structure • Main memory - only large storage media that the CPU can access directly. • Secondary storage - has large nonvolatile storage capacity. • Magnetic disks - rigid metal or glass platters covered with magnetic recording material. • Disk surface is logically divided into tracks, subdivided into sectors. • Disk controller determines logical interaction between device and computer. 85
  • 86. Storage Hierarchy • Storage systems are organized in a hierarchy based on • Speed • Cost • Volatility • Caching - process of copying information into faster storage system; main memory can be viewed as fast cache for secondary storage. 86
  • 88. OS Task: Process Management • Process - fundamental concept in OS • Process is an instance of a program in execution. • Process needs resources - CPU time, memory, files/data and I/O devices. • OS is responsible for the following process management activities. • Process creation and deletion • Process suspension and resumption • Process synchronization and interprocess communication • Process interactions - deadlock detection, avoidance and correction 88
  • 89. OS Task: Memory Management • Main Memory is an array of addressable words or bytes that is quickly accessible. • Main Memory is volatile. • OS is responsible for: • Allocate and deallocate memory to processes. • Managing multiple processes within memory - keep track of which parts of memory are used by which processes. Manage the sharing of memory between processes. • Determining which processes to load when memory becomes available. 89
  • 90. OS Task: Secondary Storage and I/O Management • Since primary storage (i.e., main memory) is expensive and volatile, secondary storage is required for backup. • Disk is the primary form of secondary storage. • OS performs storage allocation, free-space management, etc. and disk scheduling. • I/O system in the OS consists of • Device driver interface that abstracts device details • Drivers for specific hardware devices 90
  • 91. OS Task: File System Management • File is a collection of related information - represents programs and data. • OS is responsible for • File creation and deletion • Directory creation and deletion • Supporting primitives for file/directory manipulation. • Mapping files to disks (secondary storage). • Backup files on archival media (tapes). 91
  • 92. OS Task: Protection and Security • Protection mechanisms control access of processes to user and system resources. • Protection mechanisms must: • Distinguish between authorized and unauthorized use. • Specify access controls to be imposed on use. • Provide mechanisms for enforcement of access control. • Security mechanisms provide trust in system and privacy • authentication, certification, encryption etc. 92
  • 93. Operating Systems: How are they organized? • Simple • Only one or two levels of code • Layered • Lower levels independent of upper levels • Modular • Core kernel with Dynamically loadable modules • Microkernel • OS built from many user-level processes 93
  • 94. OS Structure - Simple Approach • MS-DOS - provides a lot of functionality in little space. • Not divided into modules, Interfaces and levels of functionality are not well separated 94
  • 95. Original UNIX System Structure • Limited structuring, has 2 separable parts • Systems programs • Kernel • everything below system call interface and above physical hardware. • Filesystem, CPU scheduling, memory management 95
  • 96. Layered OS Structure • OS divided into number of layers - bottom layer is hardware, highest layer is the user interface. • Each layer uses functions and services of only lower- level layers. • THE Operating System and Linux Kernel has successive layers of abstraction. 96
  • 97. Monolithic vs. Microkernel OS • Monolithic OSes have large kernels with a lot of components • Linux, Windows, Mac • Microkernels moves as much from the kernel into “user” space • Small core OS components running at kernel level • OS Services built from many independent user-level processes • Communication between modules with message passing • Benefits: • Easier to extend a microkernel • Easier to port OS to new architectures • More reliable and more secure (less code is running in kernel mode) • Fault Isolation (parts of kernel protected from other par • Detriments: • Performance overhead severe for naïve implementation 97
  • 98. A microkernel OS 98 Slide adapted from http://web.cecs.pdx.edu/~walpole/class/cs533/fall2015/home.html
  • 100. Virtual Machines 100 Hardware Virtual Machine Monitor (VMM) (aka Hypervisor) OS Application OS Application Virtual Machine 1 OS Application Virtual Machine 2 Virtual Machine 3
  • 101. Virtual Machines 101 • Use cases ●Resource configuration ●Running multiple OSes, either the same or different OSes ●Run existing OS binaries on different architecture
  • 102. Summary of Lecture set 1 • What is an operating system? • Operating systems history • Computer system and operating system structure 102