Slides for week 1 - Computing Science
Download
Report
Transcript Slides for week 1 - Computing Science
CMPT 300 Day: Operating System
Instructor: Senqiang Zhou
TA: Rong Ge
{szhoua, rge}@cs.sfu.ca
What Is This Course About?
2
Office Hours & Places
Instructor:
Time: Tue. 10:00-12:00
Fri. 14:00-15:00
Place: MTF109 North - CSIL Linux Study Area
E-MAIL List: [email protected]
Wed 11:00-12:00
TA:
Time: Mon. 14:30-15:30
Place: ASB 9911
ACS SFU account desk at Strand Hall
Course web-page:
http://www.cs.sfu.ca/CC/300/szhoua/
3
Grading
Four assignments count for 20%.
One term project counts for 15%.
One 1-hour mid-term exam counts for
20%.
Covers Ch 1 to Ch 3 .
One 3-hour final exam counts for 45%.
Covers Ch1 to Ch 6.
4
Pre-requisites
C/C++:
Basic hardware knowledge:
Necessary for term project
Necessary to understand the codes in
textbook
CPU, memory, bus, hard disk, I/O devices
Basic data structures:
Queue, stack, etc.
5
Chapter 1
Introduction
6
Outline
Definitions of operating system
History of operating systems
Categories of operating systems
Computer hardware review
Operating system concepts
System calls
7
Why Do We Need OS?
Many resources
Many tasks
Hardware: processors, memory, disks, printers,
keyboard, monitors, network interfaces, …
Software: compilers, office tools, browsers,
games, …
Programming, surfing web, handling emails,
solving equations, playing music, …
Many users
Share the resources: fairness Vs. Efficiency
8
A Computer Without OS
Consider a daily task: read data from
diskette
Basic commands: 13 parameters
Controller chips
Disk address, #blocks to read, #blocks per
track….
23 status and error field
Do you want to program the hardware
directly?
A simpler interface is needed!
9
The Benefits of OS
Hide the tedious details
Provide a variety of services: system calls
They are out of the user’s interest
E.g., to access data, only need to specify the file
name.
A set of procedures
an be called by programs using special
instructions.
A simple interface
Present key features to programmer
Meet requirements from many programs
10
OS As A Virtual Machine
Virtual machine/extended machine
Hide the underlying hardware
Access hardware through a set of system
calls
Trade-off
Higher efficiency in program development
and system management
More important with complex software
Less efficiency in program execution
Less important with faster machine
11
OS As A Resource Manager
Multiplexing (sharing) resources
In time
In space
Users/programs get parts of resources
Main memory, disk, etc.
Protecting resources
Users/programs take turns using resources
CPU, printers, etc.
E.g., user’s memory space
Issues about a good manager
Fairness, efficiency, safety, …
12
What Is An Operating System?
Provide
user
programs
with a
simpler
interface
Banking
system
Airline
reservation
Web browser
Compilers
Editors
Command
interpreter
Operating system
User
programs
System
programs
Machine language
Micro-architecture
Hardware
Physical devices
Manage
resources
13
Outline
What is an operating system?
History of operating systems
Categories of operating systems
Computer hardware review
Operating system concepts
System calls
14
History of Operating Systems
OS and architecture of computers
Computer evolves so does OS
To provide better service OS has impact
on computer design
Keep evolving through years (1944-)
Four generations so far during 60 years
Speed, volume, storage, interface…
Most important: price keeps dropping
How many generations for car industry?
15
The First Generation Computer
Vacuum tubes and plug-boards
Applications:
Straightforward numerical calculations
Absolutely no game!
Scenario
1944-1955
Huge volumes, slow speed, low stability, expensive!
Single group of people designed, built, programmed,
operated and maintained a machine
All in absolute machine language: no assembly language
No operating system
People did all the tasks.
16
The Second Generation OS
Transistors and batch systems
1955-1965
Applications
Scientific and engineering calculation
Programming Language: FORTRAN
IBM 1401
IBM 7094
Read batch
of jobs onto
tape
Cards from
programmers
Input tape
Do computing
IBM 1401
Print out
Output
tape
17
Ancestor of Today’s OS
Batch system
Load next job
A typical input job: series of commands
Read a job from tape run the job
write output onto a output tape
$JOB$FORTRAN$LOAD$RUN
Examples:
FMS, IBSYS
18
The Third Generation OS
Features: ICs and multiprogramming
1965-1980
Applications
Numerical calculations in science &
engineering
Word-oriented, large-scale scientific computers
Massive commercial data processing
Character-oriented, commercial computers
19
Key Advances in 3rd Gen OS
Multiprogramming
Spooling
Run job 2 while
job 1 waiting for I/O
Keep CPU busy
Job 3
Job 2
Job 1
OS
Memory
partitions
Read jobs from cards to disk asap
Load new jobs from disk whenever old job done
Time sharing
CPU is allocated in turn
Different from multiprogramming
20
Milestones
IBM OS/360
M.I.T. CTSS
M.I.T. MULTICS
Ken Thompson UNIX
AT&T UNIX System V
UC Berkeley UNIX BSD
IEEE POSIX
Andrew S. Tanenbaum MINIX
Linus Torvalds Linux
21
The Fourth Generation OS
Personal computers
1980-now
VLSI circuits
Cheap: an individual has her own computer
Milestones
Kildall CP/M for Intel 8080, Z80
MS-DOS/BASIC for IBM PC
Engelbart GUI
MS Windows, Windows NT
UNIX X Windows
Network & distributed operating systems
22
Outline
What is an operating system?
History of operating systems
Categories of operating systems
Computer hardware review
Operating system concepts
System calls
23
Categories of OS
Mainframe operating systems
Server operating systems
Multiprocessor operating systems
Personal computer operating systems
Real-time operating systems
Embedded operating systems
Smart card operating systems
24
Mainframe Operating Systems
Characters of mainframe computers
Features of OS
Strong I/O capability, e.g., 1000 disks, TB
space
High-end servers: web server, B2B server
Batch (background)
Transaction processing (interactive)
Timesharing
Example: IBM OS/390
25
Server Operating Systems
Hardware platforms
Services
Very large personal computers or
workstations
Printing
File accessing
Web
Examples
UNIX, Windows 2000, Linux
26
Multiprocessor Operating Systems
Multiple CPUs within a single system
Parallel computers:
Multi-computers:
Local memory, connected via LAN, tightly coupled
Multiprocessors:
Local memory, connected via WAN, loosely coupled
share memory, connected via BUS
Features of OS
Variations of the server operating systems
Special features for communication and connectivity
between CPUs
27
Personal Computer OS
User friendly interface
Easy to manipulate
Abundant application software: word
processing, spreadsheets, internet access,
game…
Examples
Windows 98, Windows 2000
Macintosh operating system
Linux
28
Outline
What is an operating system?
History of operating systems
Categories of operating systems
Computer hardware review
Operating system concepts
System calls
29
Components of A Computer
CPU
System bus: connect all components
Memory
Monitor
Keyboard
Video
controller
Keyboard
controller
Floppy
disk
driver
Hard
disk
driver
Floppy
disk
controller
Hard disk
controller
Bus
I/O Devices
30
CPU (Processor)
Basic model
Fetching instruction decoding executing
Different CPUs have different instruction sets.
Registers
Program counter: pointer to next instruction
PSW: program status word
Condition code bit, the mode (kernel or user), etc.
Stack pointer: point to the top of current stack
General registers: hold temporary results
31
Working Modes
Two modes in CPU
Kernel mode: full capability
User mode: I/O, memory protection
instructions are disallowed.
System calls: get OS service for user
program, switch to kernel mode by TRAP
instruction.
User Program
System Call
User mode
User Program
OS
Service Done
Kernel mode
User mode
32
Memory Hierarchy
Reason: Trade off between speed and Cost
Typical access
time
Typical capacity
1 nsec
Register
<1 KB
2 nsec
Cache
1 MB
10 nsec
Main memory
10 msec
Magnetic disk
5-100 GB
100 sec
Magnetic tape
20-100 GB
RAM
64MB-1G
33
Memory Management
Hold multiple programs in main memory
Improve CPU utilization. Why?
Problems
Protection
Program A is not allowed to fetch data within program B
Protect kernel from users’ programs
Relocation
Each program starts from logical address 0
How to load and allocate them into main memory?
34
Base/Limit Registers
0xFFFFFFF
Base register
Record the size of program + data
Limit of addresses
Limit
User
program
and data
Virtual address physical address
User
program
and data
Limit register
Point to the start of a program
Its content is added to every program
address
Base
Base = 4096, limit = 6114
Virtual addr = 2000 physical addr
= 2000+4096=6096 < limit, legal!
MMU: memory management unit
Operating
system
0
35
Split Program and Data
Why: multiple users
may run a same
program
Registers
when
running
program 1
How: base/limit
Limit-2
registers for program
Base-2
and data, respectively
Limit-1
Overhead of switching:
Base-1
context switch
Registers
when
running
program 2
Limit-2
User-2
data
Base-2
User-1
data
User
program
Limit-1
Base-1
Operating
system
36