Introduction To Operating Systems
Introduction To Operating Systems
Chapter 1
Class outline
Memory management, address translation, and virtual memory Operating system management of I/O File systems Security & protection Distributed systems (as time permits)
Chapter 1
2
Overview: Chapter 1
What is an operating system, anyway? Operating systems history The zoo of modern operating systems Review of computer hardware Operating system concepts Operating system structure
Chapter 1
Abstracts and standardizes the interface to the user across different types of hardware
Virtual machine hides the messy details which must be performed Each program gets time with the resource Each program gets space on the resource Use hardware efficiently Give maximum performance to each user
Chapter 1
Vacuum tubes Plug boards Transistors Batch systems Integrated circuits Multiprogramming Large scale integration Personal computers Systems connected by high-speed networks? Wide area resource management?
Chapter 1
5
Enter it into the computer (might require rewiring!) Run it Record the results
Computer was idle during first and last steps Computers were very expensive!
Chapter 1
Bring cards to 1401 Read cards onto input tape Put input tape on 7094 Perform the computation, writing results to output tape Put output tape on 1401, which prints output
Chapter 1
7
$END
Chapter 1
Spooling
Original batch systems used tape drives Later batch systems used disks for buffering
Operator read cards onto disk attached to the computer Computer read jobs from disk Computer wrote job results to disk Operator directed that job results be printed from disk
Computer overlapped I/O of one job with execution of another Better utilization of the expensive CPU Still only one job active at any given time
Chapter 1
9
Job 3 Job 2
Memory partitions
Operating system protected from each job as well Resources (time, hardware) split between jobs Still not interactive
User submits job Computer runs it User gets results minutes (hours, days) later
Chapter 1
10
Timesharing
Initially used for batch systems Cheaper hardware terminals -> interactive use No more priesthood Quick turnaround meant quick fixes for problems
Chapter 1
11
Chapter 1
12
Components of a simple PC
Outside world
Video controller
USB controller
Network controller
CPU Memory
CS 1550, cs.pitt.edu (originaly modified by Ethan
13
CPU internals
Execute unit Execute unit Execute unit
Fetch unit Fetch unit Decode unit Execute unit Fetch unit
Decode unit
Buffer
Decode unit
Pipelined CPU
Superscalar CPU
Chapter 1
14
Storage pyramid
Capacity < 1 KB 1 MB 256 MB Registers Cache (SRAM) Main memory (DRAM) Access latency 1 ns 25 ns 50 ns
Better
40 GB
Better
Magnetic disk
Magnetic tape
5 ms
50 sec
> 1 TB
Latencies are smaller at the top of the hierarchy Capacities are larger at the bottom of the hierarchy
Solution: move data between levels to create illusion of large memory with low latency
Chapter 1
15
head
Up to two surfaces per platter One or more platters per disk Tracks broken into sectors
sector
surfaces
spindle
actuator
16
Chapter 1
Memory
Address
0x2ffff
0x2b000
0x27fff 0x23000 0x1dfff
0x2bfff 0x29000
0x24fff 0x23000 0x1dfff
Operating system
0 0
Operating system
Single base/limit pair: set for each process Two base/limit registers: one for program, one for data
Chapter 1
17
1: Interrupt
Instructionn Instructionn+1
Disk controller 4
3: Return
Request sent to controller, then to disk Disk responds, signals disk controller which tells interrupt controller Interrupt controller notifies CPU
Chapter 1
18
Many of these should be familiar to Unix users Processes (and trees of processes) Deadlock File systems & directory trees Pipes Well cover all of these in more depth later on, but its useful to have some basic definitions now
Chapter 1
19
Processes
Address space (memory) the program can use State (registers, including program counter & stack pointer)
OS keeps track of all processes in a process table Processes can create other processes
Process tree tracks these relationships A is the root of the tree A created three child processes: B, C, and D C created two child processes: E and F D created one child process: G
20
Chapter 1
Stack
Statically declared variables Areas allocated by malloc() or new Automatic variables Procedure call information
Stack
Data Data
Text 0
CS 1550, cs.pitt.edu (originaly modified by Ethan
Chapter 1
Deadlock
Potential deadlock
CS 1550, cs.pitt.edu (originaly modified by Ethan
Actual deadlock
Chapter 1
22
bin
cse
grads
amer4
classes stuff
research stuff
Chapter 1
23
Interprocess communication
Processes want to exchange information with each other Many ways to do this, including
Network Pipe (special file): A writes into pipe, and B reads from it
Chapter 1
24
System calls
The OS is able to do so The service is permitted for this program at this time Dont want programs reading data into other programs memory!
Chapter 1
25
System call:
read(fd,buffer,length)
Program pushes arguments, calls library Library sets up trap, calls OS OS handles system call Control returns to library Library returns to user program
Dispatch
0
CS 1550, cs.pitt.edu (originaly modified by Ethan
Chapter 1
26
Description
Open a file for reading and/or writing Close an open file Read data from a file into a buffer Write data from a buffer into a file Move the current pointer for a file Get a files status information (in buffer) Create a new directory Remove a directory (must be empty) Create a new entry (name2) that points to the same object as name1 Remove name as a link to an object (deletes the object if name was the only link to it)
Chapter 1
27
Description
Create a child process identical to the parent
Wait for a child to terminate Replace a process core image
exit(status)
s = chdir(dirname) s = chmod(name,mode)
s = kill(pid,signal)
seconds = time(&seconds)
Chapter 1
28
A simple shell
while (TRUE) { /* repeat forever */ type_prompt( ); /* display prompt */ read_command (command, parameters) /* input from terminal */ if (fork() != 0) { /* fork off child process */ /* Parent code */ waitpid( -1, &status, 0); /* wait for child to exit */ } else { /* Child code */ execve (command, parameters, 0); /* execute command */ } }
Chapter 1
29
Monolithic OS structure
Main procedure
Service routines
Utility routines
Chapter 1
30
Virtual machines
App1 App2 App3
System calls
I/O instructions Calls to simulate I/O Real I/O instructions
Linux
VMware
Windows NT
VMware Linux Bare hardware
FreeBSD
VMware
Allows users to run any x86-based OS on top of Linux or NT Only virtual machine failsrest of underlying OS is fine Virtual machine keeps things separated
Chapter 1
31
Microkernels (client-server)
Client process Client process Process server Terminal server
File server
Memory server
User mode
Kernel mode
Microkernel
Chapter 1
32
Metric units
Exp.
10-3 10-6 10-9 10-12 10-15 10-18
0.001
Number
0.000001 0.000000001 0.000000000001 0.000000000000001 0.000000000000000001
Prefix
milli micro nano pico femto atto
Exp.
103 106 109 1012 1015 1018
Number
1,000 1,000,000 1,000,000,000 1,000,000,000,000 1,000,000,000,000,000 1,000,000,000,000,000,000
Prefix
Kilo Mega Giga Tera Peta Exa
Chapter 1
33