Outline • Operating System Organization • Operating System Examples – Basic functions

advertisement
Outline
• Operating System Organization
– Basic functions
– Factors in OS Design
– Basic implementation considerations
• Operating System Examples
Basic OS Responsibilities
• Create an abstract machine environment
– A nicer environment than bare hardware
– Consists of multiple, autonomous abstract
components
• Coordinate the use of the components
– Resource manager
– Manage according to the policies of the
machine’s administrator
5/29/2016
COP4610
2
Basic OS Functions
•
•
•
•
Device management
Process, thread, and resource management
Memory management
File management
5/29/2016
COP4610
3
Device Management
Device-Independent
Part
Device-Dependent
Part
Device-Dependent
Part
Device
Device
5/29/2016
COP4610
Device-Dependent
Part
…
Device
4
Device Management – cont.
Application
Process
System Interface
File
Manager
Device-Independent
Device-Dependent
Hardware Interface
Command
Status
Data
Device Controller
5/29/2016
COP4610
5
Device Management – cont.
read(device, …);
1
9
8b
Data
System Interface
Device Status Table
read driver
2
4
7
Device
Handler
write driver
6
Interrupt
Handler
8a
5
Hardware Interface
Command
Status
Data
Device Controller
5/29/2016
COP4610
6
Device Management – cont.
5/29/2016
COP4610
7
Life Cycle of an I/O Request
5/29/2016
COP4610
8
Process Management
5/29/2016
COP4610
9
Memory Management
Isolation &
Sharing
Process
Manager
Block
Allocation
Primary
Memory
5/29/2016
COP4610
Virtual
Memory
Storage
Devices
10
Memory Management – cont.
5/29/2016
COP4610
11
Memory Management – cont.
5/29/2016
COP4610
12
Memory Management – cont.
5/29/2016
COP4610
13
File System Management
5/29/2016
COP4610
14
Basic OS Functions – cont.
5/29/2016
COP4610
15
Basic OS Functions – cont.
Process/Thread
Admin
Scheduler
Virtual
Memory
File
Management
Synchronization
Device
Management
IPC
Deadlock
Management
Interrupt
Handler
Resource
Management
Protection
Mechanisms
5/29/2016
Memory
Allocation
COP4610
16
Basic OS Functions – cont.
Application
Software
Application
Software
Application
Software
Application
Software
Other System
Software
Other System
Software
Other System
Software
Other System
Software
Other OS Functions
Other OS Functions
Other OS Functions
Other OS Functions
Kernel Functions
Nucleus Functions
Nucleus Functions
Nucleus Functions
Skeletal Nucleus
(a) Monolithic
5/29/2016
(b) Modular
(c) Extensible
COP4610
(d) Layered
17
Factors in OS Design
•
•
•
•
•
•
Performance
Protection and security
Correctness
Maintainability
Commercial factors
Standard and open systems
5/29/2016
COP4610
18
Typical Computer at 1980 and 2000
5/29/2016
COP4610
19
Standard and Open Systems
• Open system
– A system consists of diverse computers, operating
systems, and applications for problem solving
• Strategies
– Application integration
– Portability
– Interoperability
5/29/2016
COP4610
20
Java Virtual Machines
• A further implementation of the virtual
machine concept
– It provides a virtual machine environment
regardless of the hardware
– Java programs can run on any machine that has a
Java virtual machine
– It provides attractive features in an open system
environment
5/29/2016
COP4610
21
Dual-mode Operation
• Ensure proper operation of a computer system
– Protect the operating system and all other programs and
their data from any malfunctioning program
– Protection is needed for any shared resource
• Dual-mode provides a means of doing that
– System operates in two modes
• User mode
• System mode
– Privileged instructions
• I/O instructions are privileged instructions
5/29/2016
COP4610
22
Dual-mode Operation – cont.
• Supervisor mode
– all instructions are legal
– all addresses are absolute physical addresses
(base and bound are not used)
• User mode
– instructions that modify control registers are
illegal
– all addresses must be less than bound and have
base added to them
5/29/2016
COP4610
23
Privileged Instructions
• Instructions that can only be executed in the
supervisor mode are called supervisor, privileged,
or protected instructions
• I/O instructions are privileged instructions
– A user program in user mode cannot perform its own
I/O
• Instruction to change the mode is a privileged
instruction
• Instruction to set the halt flag is a privileged
instruction
5/29/2016
COP4610
24
Trap Instruction
5/29/2016
COP4610
25
Trap Instruction – cont.
…
fork();
…
Trap Table
fork() {
…
trap
N_SYS_FORK()
…
}
Kernel
sys_fork()
sys_fork() {
/* system function */
…
return;
}
5/29/2016
COP4610
26
Kernels
• Kernels
– Critical parts of OS that run in supervisor mode
• Have access to other parts of the kernel
– Trusted software
• Extensions to the OS execute in user mode
5/29/2016
COP4610
27
Requesting Services from O.S.
• Two techniques
– System call
– Message passing
5/29/2016
COP4610
28
How to Make a System Call – cont.
• For the system
– through a trap instruction which causes an interrupt
• Hardware saves PC and current status information
• Hardware changes mode to system mode
• Hardware loads PC from system call interrupt vector
location.
• Execute the system call interrupt handler
• return from the handler, restores PC and other saved status
information
• User process continues.
5/29/2016
COP4610
29
System Call Flow of Control
5/29/2016
COP4610
30
How to Make a System Call – cont.
• Parameter passing
– Through registers
• System call number passed through register
• Parameters are passed through registers
• Returned value is also passed through a register to
C/C++
– Through a table in memory
• Pass the address of the table in a register
– Through the stack
• Push the parameters on the stack by the user program
• Pop the parameters off the stack by the O.S.
5/29/2016
COP4610
31
Requesting Services – cont.
• Two techniques
– System call
– Message passing
5/29/2016
COP4610
32
Operating System Examples
•
•
•
•
•
•
UNIX
MACH
MS-DOS
Windows NT
OS/2
MacOS
5/29/2016
COP4610
33
UNIX
• One of the most popular operating systems
• First version released in 1969
– By Ken Thompson at Bell Lab
– Widely used in universities and research
organizations
– Time-sharing system
– Supports multiple processes
– Disk files and I/O devices are treated similarly
5/29/2016
COP4610
34
History of UNIX Versions
5/29/2016
COP4610
35
Advantages of UNIX
• Written in a high-level language.
• Distributed in source form.
– Available on the web
• http://www.freebsd.org/availability.html
• Provided powerful operating-system
primitives on an inexpensive platform.
• Small size, modular, clean design.
5/29/2016
COP4610
36
UNIX Design Principles
• Designed to be a time-sharing system
• Has a simple standard user interface that can be
replaced.
• File system with multilevel tree-structured
directories.
• Files are supported by the kernel as unstructured
sequences of bytes.
• Supports multiple processes; a process can easily
create new processes.
• High priority given to making system interactive,
and providing facilities for program development.
5/29/2016
COP4610
37
UNIX System Structure
Interactive User
Device Driver
Device Driver
…
Device Driver
5/29/2016
Driver Interface
Libraries
Application
Commands
…
Programs
OS System Call Interface
Trap Table
Monolithic Kernel Module
•Process Management
•Memory Management
•File Management
•Device Mgmt Infrastructure
COP4610
38
Windows NT
– 32-bit preemptive multitasking operating system for modern
microprocessors.
– Key goals for the system:
•
•
•
•
•
•
•
portability
security
POSIX compliance
multiprocessor support
extensibility
international support
compatibility with MS-DOS and MS-Windows applications.
– Uses a micro-kernel architecture.
– Available in two versions, Windows NT Workstation and Windows
NT Server.
– In 1996, more NT server licenses were sold than UNIX licenses
5/29/2016
COP4610
39
History of Windows NT
– In 1988, Microsoft decided to develop a “new
technology” (NT) portable operating system that
supported both the OS/2 and POSIX APIs.
– Originally, NT was supposed to use the OS/2 API
as its native environment but during development
NT was changed to use the Win32 API, reflecting
the popularity of Windows 3.0.
5/29/2016
COP4610
40
Windows NT Design Principles
• Extensibility — layered architecture.
– NT executive, which runs in protected mode, provides the
basic system services.
– On top of the executive, several server subsystems
operate in user mode.
– Modular structure allows additional environmental
subsystems to be added without affecting the executive.
5/29/2016
COP4610
41
Window NT Design Principles - Cont.
• Portability — NT can be moved from one
hardware architecture to another with relatively few
changes.
– Written in C and C++.
– Processor-dependent code is isolated in a dynamic link
library (DLL) called the “hardware abstraction layer”
(HAL).
• Reliability — NT uses hardware protection for
virtual memory, and software protection
mechanisms for operating system resources.
5/29/2016
COP4610
42
Window NT Design Principles - Cont.
• Compatibility — applications that follow the IEEE
1003.1 (POSIX) standard can be complied to run on
NT without changing the source code.
• Performance — NT subsystems can communicate
with one another via high-performance message
passing.
– Preemption of low priority threads enables the system to
respond quickly to external events.
– Designed for symmetrical multiprocessing.
• International support — supports different locales
via the national language support (NLS) API.
5/29/2016
COP4610
43
Windows NT Architecture
• Layered system of modules.
• Protected mode — HAL, kernel, executive.
• User mode — collection of subsystems
– Environmental subsystems emulate different
operating systems.
– Protection subsystems provide security functions.
5/29/2016
COP4610
44
Windows NT Architecture
5/29/2016
COP4610
45
Summary
• Basic functions of OS
–
–
–
–
Device management
Process and resource management
Memory management
File management
• Several factors are important to OS design
• Implementation considerations
– Dual mode
• OS examples
– UNIX and Windows NT
5/29/2016
COP4610
46
Download