Lec1 Intro
Lec1 Intro
Operating Systems
Lecture 1
Today’s Agenda
Basic Course information.
What is an OS? What does it do?
A Brief History of OS’s.
Hardware overview
A peek at Unix
System Calls
Overview of OS components
User space versus Kernel space
Operating Systems 2
Overview
Teaching Assistants:
Required Textbook:
Modern Operating Systems, 3rd
Ed.,Tanenbaum, Pearson Edu., 2009
Class Website
http://www.fatih.edu.tr/~hakkoymaz
Operating Systems 3
Course Information
Prerequisites
CENG/BİLM 201 or equivalent
CENG/BİLM 252 or equivalent
C programming (Basic level)
Operating Systems 4
Why are you here?
To fulfill a requirement
To better understand other subjects
Networking
Distributedsystems
Real-time systems
Multimedia systems
Operating Systems 5
About this course…
Principles Goals
Operating Systems 6
Pain=Reward
Fast pace
Hard material
~programming
~homeworks AND quizzes
Operating Systems 7
Name some OS’s
Linux PalmOS
Unix TinyOS
Windows WinCE
Multics Spring
BSDUnix 2K
Mac/Tiger ….
Vista
Operating Systems 8
What Is an OS?
“Code” that:
Sits between programs & hardware
Sits between different programs
Sits betweens different users
What happens if two applications simultaneously use
But what does it do? the printer?
Provides an orderly and controlled allocation of the processors,
memories and I/O devices among the various programs competing
for them
Loose analogy:
Government: creates and enforces laws that govern
resources (money, land, houses, vehicles, oil, etc.) but
allows citizens to have freedom with using the resources
(as long as the citizen obeys laws)
Operating Systems 9
What Is an OS?
Resources Services
Allocation Abstraction
Protection Simplification
Reclamation Convenience
Virtualization Standardization
Protection CPU
Memory
Reclamation
Disk
Virtualization
Network
Operating Systems 11
What Is an OS?
Government
Operating Systems 12
What Is an OS?
Government
Income Tax
Resources The OS gives
Allocation The OS takes away
Protection
Voluntary at run time
Reclamation
Implied at termination
Virtualization
Involuntary
Cooperative
Operating Systems 13
What Is an OS?
Government
illusion of infinite, private Social security
Resources resources
Allocation
Protection Memory versus disk
Timeshared CPU
Reclamation
Virtualization
More extreme cases
possible
Operating Systems 14
History of Operating Systems
First generation 1945 – 1955 (Anarchy)
vacuum tubes, plug boards (no OS, signup sheets or
punch cards)
Second generation 1955 – 1965 (Monarchy)
transistors, batch systems
Third generation 1965 – 1980 (Feudalism)
ICs and multiprogramming
Fourth generation 1980 – present (free market)
– personal computers
Operating Systems 15
History of Operating Systems
(Monarchy)
Operating Systems 16
History of Operating Systems
(Monarchy)
Operating Systems 17
History of Operating Systems
(Feudalism) 1401 7094 50’s
Multiprogramming system
– Multiple jobs in memory – 3 rd generation
– SPOOLing - use disk as large buffer for input/output devices
– SPOOL=Simultaneous Peripheral Operation On-Line
– Timesharing=multiple users logged on, e.g., CTSS, MULTICS
Operating Systems 18
The Operating System Zoo
Mainframe operating systems
Server operating systems
Multiprocessor operating systems
Personal computer operating systems
Real-time operating systems
Embedded operating systems
Smart card operating systems
Operating Systems 19
Historical Comparison
Mainframe Mini Micro
System $/ 10:1 – 10:1 – 1:10-1:100
Worker 100:1 1:1
Salary
Goal System Overall Productivity
utilization cost
Target Capacity Features Ease of
Use
Operating Systems 20
Pentium System
Memory Chipset
I/O bus
Network
Operating Systems 22
A Typical Computer System (black
box)
CPU Memory
OS
Network
Apps
Data
Operating Systems 23
Memory-Storage Hierarchy
Operating Systems 24
A peek into Unix
Application
Kernel space/level
Portable OS Layer •User/kernel modes are
supported by hardware
Machine-dependent layer
•Some systems do not have
clear user-kernel boundary
Operating Systems 25
Unix: Application
Portable OS Layer
Machine-dependent layer
Operating Systems 26
Unix: Libraries
Machine-dependent layer
Operating Systems 27
Typical Unix OS Structure
Application
Libraries
Portable OS Layer
system calls (read, open..)
All “high-level” code
Machine-dependent layer
Operating Systems 28
Typical Unix OS Structure
Application
Libraries Bootstrap
System initialization
Interrupt and exception
I/O device driver
Portable OS Layer Memory management
Kernel/user mode
Machine-dependent layer switching
Processor management
Operating Systems 29
Typical Unix OS Structure
Application
Machine-dependent layer
Operating Systems 30
Another Look: Unix “Onion”
Applications User and Kernel
boundary
OS Service
Device
Hardware
Driver
Operating Systems 31
A small fraction of System Calls in Unix
Operating Systems 32
read (fd,buffer,nbytes)
How an Interrupt Works
(a)
Steps 3 and 4
(a) Steps in starting an I/O in (a)
device and getting interrupt (b)
(b) How the CPU is interrupted
“Interrupt handler” is a part of the
Code for the device driver
Operating Systems 33
How a System Call Works
read (fd,buffer,nbytes)
Operating Systems 34
All OS’s offer their own Syscalls
Operating Systems 36
Introducing…the “Process”
Program=code
Process=running program. Includes:
Code, data, stack, program counter, register values,
anything that describes current “state” of process
A process tree
A created two child processes, B and C
B created three child processes, D, E, and F
An OS has to manage/juggle multiple processes
at the same time!
Operating Systems 37
An example process: A Command
Shell!
A stripped down shell:
while (TRUE) { /* repeat forever */
type_prompt( ); /* display prompt */
read_command (command, parameters) /* input from terminal */
Operating Systems 38
Deadlock
Operating Systems 39
Process communication
Operating Systems 40
Is this done in user-level or kernel-level?
Operating Systems 41
Is this done in user-level or kernel-level?
Memory Management
Goals
Register
Support programs to run
Allocation and management
L2 10x
Transfers from and to
secondary storage
Memory 200x
Issues
Efficiency & convenience Disk 10Mx
Fairness
Protection Tape 100Mx
Operating Systems 42
Is this done in user-level or kernel-level?
Operating Systems 43
File System Example
File System
A typical file system User 1 ... User n
Open a file with
authentication
Read/write data in files
File system services
Close a file
Operating Systems 45
Is this done in user-level or kernel-level?
Bootstrapping
Power up a computer Boot Boot
Processor reset loader loader
Set to known state OS
Jump to ROM code sector 1
1. Load in the boot loader from OS
stable storage sector 2
2. Jump to the boot loader .
.
3. Load the rest of the .
operating system
4. Initialize and run
OS
sector n
Operating Systems 46
Design Tradeoffs
All in the kernel (Windows)
Pros:efficient?
Cons: difficult to develop new services
Almost all at user level (Exokernel)
Pros:easy to develop new apps
Cons: protection
Split between user and kernel (Unix)
Kernel:display driver and mouse driver
User: many other services, incl. novel file systems!
Operating Systems 47
You Live in Interesting Times…
Operating Systems 48