Chapter 01 OS
Chapter 01 OS
1.1 Introduction
1.2 Computer hardware review
1.3 Operating system concepts
1
1.1 Introduction
– What is an operating system
– History of operating systems
– The operating system zoo
2
What is an operating system
3
Computer system
4
What is an Operating System
5
What is an Operating System
• OS is an extended machine
– Hides the messy details which must be performed
– Presents user with a virtual machine, easier to use
• OS is a resource manager
– Each program gets time with the resource
– Each program gets space on the resource
6
History of Operating Systems
7
History of Operating Systems
8
History of Operating Systems
First generation 1945 - 1955
• Computers:ENIAC, UNIVAC…
• Operating System: No OS,
• Machine Language, plugboards
• Single group: designed, built, programmed,
operated and maintained each machine
9
History of Operating Systems
Second Generation 1955 – 1965 (1)
10
History of Operating Systems
Second Generation 1955 – 1965 (2)
11
History of Operating Systems
Second Generation 1955 – 1965 (3)
13
History of Operating Systems
Third generation 1965 – 1980 (2)
• Multiprogramming system
– three jobs in memory – 3rd generation
14
History of Operating Systems
Third generation 1965 – 1980 (3)
15
History of Operating Systems
Fourth generation 1980 – present
16
The Operating System Zoo
17
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
18
The Operating System Zoo
Mainframe operating systems
– batch
– multiprogrammed
– time-sharing, multitasking
– Application: High-End Web Server, Servers for
Business-To Business transactions
– Example: OS/390
19
The Operating System Zoo
Server operating systems
20
The Operating System Zoo
Multiprocessor operating systems
– Multiple CPU
– Share computer bus, clock
– Advantage:
• High system throughput
• High availability
• Multiprocessor system and Multicomputer system
21
The Operating System Zoo
Personal computer operating systems
22
The Operating System Zoo
Real-time operating systems
23
The Operating System Zoo
Embedded operating systems
24
The Operating System Zoo
Smart card operating systems
25
Review 1
1. Xem CPU trong máy tính? Thông số tốc độ? Tốc độ xGHz
có nghĩa là gì? Chức năng CPU
2. Bộ nhớ trong là gì? Ram dùng để làm gì? Bộ nhớ Cache,
Register là gì ở đâu? Xem thông số Ram?
3. Kể ra 2 thiết bị vào, 2 thiết bị ra?
4. Bộ nhớ ngoài là gì? Lấy 3 ví dụ? HDD là gì, xem thông số
HDD trong máy?
5. Buses là gì? Chức năng? Lấy 3 ví dụ?
6. List 4 OSs in PC environments: Market shares? Which one
having the maximum market share value? Reasons to make
that one become the best
7. List 4 Operating systems in Smart Phone environments:
The same questions as above ones.
26
1.2 Computer Hardware Review
- CPU
- Memory
- I/O Devices
- Buses
27
Computer Hardware Review
Monitor
Bus
28
Computer Hardware Review
The CPU (1)
• PC Program Counter
• SP Stack Pointer
• PSW Program Status Word
• General Registers
• Instruction Cycle
• Pipeline
• Superscalar
• System Call
29
Computer Hardware Review
The CPU (2)
30
Computer Hardware Review
The CPU (3)
31
Computer Hardware Review
The CPU (4)
32
Computer Hardware Review
The CPU (5)
33
Computer Hardware Review
Memory (1)
34
Computer Hardware Review
Memory (2)
35
Computer Hardware Review
Memory (3)
Registers:
• Small number, Fast
• Capacity:
– 32*32 bit on 32-bit CPU
– 64*64 bit on 64-bit CPU
36
Computer Hardware Review
Memory (4)
37
Computer Hardware Review
Memory (5)
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
38
Computer Hardware Review
Memory (6)
Main Memory
• RAM (Random Access Memory)
• Problem:
– How protect the program from one another and the kernel from
them all
– How to handle relocation
• Solution: CPU equipped with two special registers
• Base Register and Limit Register
• MMU (Memory Management Unit) convert Virtual Address to
Physical Address
• Context Switch; switching from one to another
39
Computer Hardware Review
Memory (7)
Relocation and Protection
• Cannot be sure where program will be loaded in memory
– address locations of variables, code routines cannot be absolute
– must keep a program out of other processes’ partitions
40
Computer Hardware Review
Memory (8)
42
Computer Hardware Review
Memory (10)
43
Computer Hardware Review
Memory (11)
46
Computer Hardware Review
I/O Devices (2)
48
Computer Hardware Review
I/O Devices (3)
Common Functions of Interrupts
• Interrupt transfers control to the interrupt service routine
generally, through the interrupt vector table, which
contains the addresses of all the service routines.
• Interrupt architecture must save the address of the
interrupted instruction.
• Incoming interrupts are disabled while another interrupt is
being processed to prevent a lost interrupt.
• A trap is a software-generated interrupt caused either by
an error or a user request.
• An operating system is interrupt driven.
49
Computer Hardware Review
I/O Devices (4)
(a) (b)
DMA
• 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.
52
Computer Hardware Review
Structure of a large Pentium system
53
Computer Hardware Review
BUS
• Cache BUS
• Local BUS
• System BUS
• ISA Industry Standard Architecture
• PCI Peripheral Component Interconnect
• USB Universal Serial BUS
• SCSI Small Computer System Interface
• IDE Integrated Drive Electronic
54
Computer Hardware Review
Personal Computer (PC)
55
1.3 Operating System Concepts
– OS Components
– System calls
– Operating system structure
56
OS Components
– Process Management
– Main Memory Management
– File management
– I/O Management
– Secondary Storage Management
– Protection and Security
57
Operating System Concepts
OS Components (1)
• Process Management
– Process is a Program in execution
– A process needs certain resources, including CPU time,
memory, files, and I/O devices, to accomplish its task.
– Tasks of process management of OS:
• Process creation and deletion.
• process suspension and resume
• Provision of mechanisms for:
- Process synchronization
- Interprocess communication
- Prevent or avoid deadlock
58
Operating System Concepts
OS Components (2)
• A process tree
– A created two child processes, B and C
– B created three child processes, D, E, and F
59
Operating System Concepts
OS Components (3)
60
Operating System Concepts
OS Components (4)
62
Operating System Concepts
OS Components (6)
• Main Memory Management:
– Motivations:
• Increase system performance
• Maximize memory utilization
– Task of main memory of management:
• Keep track of which parts of memory are currently being used
and by whom.
• Decide which processes to load when memory space becomes
available.
• Allocate and deallocate memory space as needed
63
Operating System Concepts
OS Components (7)
• File management
– File system
• File
• Directory
– Task of file management of OS:
• Create and delete File/Dicrectory
• Manipulate: rename, copy, move, new,…
• Mapping files onto secondary storage.
• File backup on stable (nonvolatile) storage media
64
Operating System Concepts
OS Components (8)
• I/O Management
– Hide the specialty of H/W devices
– Task of I/O Management of OS:
• Manage main memory for the devices using
caching, buffering, and spooling
• Maintain and provide a general device-driver
interfaces
• Drivers for specific hardware devices.
66
Operating System Concepts
OS Components (10)
67
Operating System Concepts
OS Components (11)
68
Operating System Concepts
OS Components (12)
69
Operating System Concepts
Operating System Services
• One set of operating-system services provides
functions that are helpful to the user:
– User interface - Almost all operating systems have a user interface (UI)
• Varies between Command-Line (CLI), Graphics User Interface
(GUI)
– Program execution - The system must be able to load a program into
memory and to run that program, end execution, either normally or
abnormally (indicating error)
– Control access to I/O device.
– File-system manipulation
70
Operating System Concepts
Operating System Services
71
System Calls
– Making System Calls
– Major POSIX System Calls
– Examples of System Calls
72
System Calls
Making System Calls (1)
74
System Calls
POSIX System Calls (1)
75
System Calls
POSIX System Calls (2)
76
System Calls
POSIX System Calls (3)
77
System Calls
POSIX System Calls (4)
78
System Calls
Examples (1)
81
System Calls
Examples (4)
82
System Calls
84
Operating System Structure
Monolithic system (1)
85
Operating System Structure
Monolithic system (2)
86
Operating System Structure
Monolithic system (3) : Example
• Monolithic
– MS-DOS – written to
provide the most
functionality in the least
space:
• not divided into modules;
• Although MS-DOS has some
structure, its interfaces and
levels of functionality are not
well separated
87
Operating System Structure
Layered System (1)
• Many Layers
• Each layer has well defined functions
• Upper layer can only calls functions of
closely lower layer
• Advantages:
– Easier to extend
– Easier to debug from lower to upper layer
88
Operating System Structure
Layered System (2): Example
89
Operating System Structure
Layered System (3): Example
processes
processes
processes
processes
programming kernel kernel kernel
interface
VM1 VM2 VM3
kernel Virtual-machine
implementation
hardware
hardware
Non-virtual machine
Virtual machine system model
system model
91
Operating System Structure
Virtual Machine (2)
92
Operating System Structure
Virtual Machine (3)
93
Operating System Structure
Client-server model (1)
94
Operating System Structure
Client-server model (2)
95
Operating System Structure
Microkernel: Example
Microkernel
OS design: The operating system is divided into microkernel
(CMU Mach OS - 1980)
– Moves as much from the kernel into “user” space
– kernel microkernel
– Communication takes place between user modules using message
passing.
Application POSIX
X-application application
File POSIX
server X-window
server server
96
1. Explain terms: multiprogramming, Register (Program
counter, stack pointer, Program status word).
2. List all security functions are provided by your OS?
3. Study to know how to turn on your firewall and block
some programs.
4. One reason GUIs were initially slow to be adopted was
the cost of the hardware needed to support them. How
much video RAM is needed to support a 25 line × 80 row
character monochrome text screen? How much for a 1024
× 768 pixel 24-bit color bitmap? What was the cost of this
RAM at 1980 prices ($5/KB)? How much is it now?
5. List 5 antivirus softwares? Which one is the best in your
opinion?
97
Reivew 1
1. List 4 Operating systems in PC environments
– Market shares? Which one having the maximum
market share value?
– Reasons to make that one become the best one?
2. List 4 Operating systems in Smart Phone
environments
– The same questions as above ones.
98
Review 2
• Install Ubuntu OS
• Virtual Machine: VMWare, Virtual Box
99
Review 3: OS Structure
• Android OS
http://www.techotopia.com/index.php/
An_Overview_of_the_Android_Architecture
• Mac OS X
https://developer.apple.com/library/mac/
documentation/Darwin/Conceptual/
KernelProgramming/Architecture/Architecture.html
• iOS
http://code.tutsplus.com/tutorials/exploring-the-ios-
sdk--mobile-13959
10
Review 2
1. List 5 OS & its market share in PC environment
2. The same question with Smart Phone
environment?
3. List some security functions are provided by your
OS?
4. List 5 antivirus softwares? Which one is the best
in your opinion?
5. Study to know how to turn on your firewall and
block some programs…
10