Upload
dwain-hicks
View
218
Download
0
Embed Size (px)
Citation preview
OSes: 3. OS Structs 1
Operating SystemsOperating Systems
ObjectivesObjectives– summarise OSes from several perspectivessummarise OSes from several perspectives
Certificate Program in Software DevelopmentCSE-TC and CSIM, AITSeptember -- November, 2003
3. OS Structures(Ch. 3, S&G)
OSes: 3. OS Structs 2
ContentsContents
1.1. OS ComponentsOS Components
2.2. OS ServicesOS Services
3.3. System CallsSystem Calls
4.4. System StructureSystem Structure
5.5. Virtual MachinesVirtual Machines
6.6. OS Design and ImplementationOS Design and Implementation
OSes: 3. OS Structs 3
1. OS Components1. OS Components
1.1.1.1. Process/thread ManagementProcess/thread Management
1.2.1.2. Main Memory ManagementMain Memory Management
1.3.1.3. Secondary Storage ManagementSecondary Storage Management
1.4.1.4. I/O System ManagementI/O System Management
1.5.1.5. File ManagementFile Management
1.6.1.6. Protection/SecurityProtection/Security
1.7.1.7. NetworkingNetworking
OSes: 3. OS Structs 4
1.1. Process/thread Mgmt.1.1. Process/thread Mgmt.
Programs are Programs are passivepassive
Processes Processes executeexecute, each with its own , each with its own program counter, but shared resourcesprogram counter, but shared resources
Threads are Threads are light-weightlight-weight processes processes– much simpler state and control much simpler state and control
continued
OSes: 3. OS Structs 5
Management tools:Management tools:– creation/deletioncreation/deletion– suspension/resumptionsuspension/resumption– synchronisationsynchronisation– communicationcommunication– resource allocation/releaseresource allocation/release– deadlock handlingdeadlock handling
OSes: 3. OS Structs 6
1.2. Main Memory Mgmt.1.2. Main Memory Mgmt.
Depends on system and hardware supportDepends on system and hardware support
Track memory usageTrack memory usage
Decide on process schedulingDecide on process scheduling
Allocate/deallocate memory to jobsAllocate/deallocate memory to jobs
OSes: 3. OS Structs 7
1.3. Secondary Storage Mgmt.1.3. Secondary Storage Mgmt.
Storage and retrievalStorage and retrieval
SchedulingScheduling
Free space managementFree space management
Efficient usage is Efficient usage is essentialessential
OSes: 3. OS Structs 8
1.4. I/O System Mgmt.1.4. I/O System Mgmt.
AimAim: hide device peculiarities: hide device peculiarities
Features:Features:– buffering, caching, spoolingbuffering, caching, spooling– support an abstract interface to devicessupport an abstract interface to devices– support a range of specific devicessupport a range of specific devices
OSes: 3. OS Structs 9
1.5. File Mgmt.1.5. File Mgmt.
Many types of file systems, with different Many types of file systems, with different properties:properties:– speed, capacity, data transfer rate, speed, capacity, data transfer rate,
access method (e.g. sequential, random)access method (e.g. sequential, random)
AimAim: provide a consistent, logical view:: provide a consistent, logical view:– files and directoriesfiles and directories
continued
OSes: 3. OS Structs 10
Features:Features:– creation/deletion of files & directoriescreation/deletion of files & directories– manipulationmanipulation
open, closeopen, close read, write, seekread, write, seek get/set attributesget/set attributes
– mapping to physical storagemapping to physical storage– backup/archivingbackup/archiving
OSes: 3. OS Structs 11
1.6. Protection/Security1.6. Protection/Security
ProtectionProtection: controlling the access of : controlling the access of programs, processes, or users to the programs, processes, or users to the system’s resourcessystem’s resources– e.g. CPU, files, peripherialse.g. CPU, files, peripherials
Network aspects of protection are Network aspects of protection are becoming increasingly importantbecoming increasingly important
OSes: 3. OS Structs 12
1.7. Networking1.7. Networking
Main machine types: Main machine types: – multiprocessor systemsmultiprocessor systems– distributed systemsdistributed systems
Two main communication models:Two main communication models:– message passingmessage passing– shared memoryshared memory
continued
OSes: 3. OS Structs 13
Communication ModelsCommunication Models Fig. 3.5, p.66
process A M
process B M
kernel M
1
2
Message Passing
process A
process B
shared memory
1
2
kernel
Shared memory
OSes: 3. OS Structs 14
2. OS Services2. OS Services
User services:User services:– program execution; I/O operations;program execution; I/O operations;
file manipulation; communication;file manipulation; communication;error detectionerror detection
System efficiency:System efficiency:– resource allocation; accounting;resource allocation; accounting;
protectionprotection
OSes: 3. OS Structs 15
3. System Calls3. System Calls
Process controlProcess control File manipulationFile manipulation Device manipulationDevice manipulation Information maintenanceInformation maintenance CommunicationsCommunications
OSes: 3. OS Structs 16
4. System Structure4. System Structure UNIX (fig. 3.7, p.70)UNIX (fig. 3.7, p.70)
system call interface to kernel
kernel interface to the kernel
signalsterminal handling
character I/O systemterminal drivers
file systemswapping
block I/O systemdisk and tape drivers
CPU schedulingpage replacementdemand pagingvirtual memory
terminal controllersterminals
device controllersdisks and tapes
memory controllersphysical memory
shells and commandscompilers and interpreters
system libraries
USERS
OSes: 3. OS Structs 17
Layered ApproachLayered Approach Fig. 3.8, p.71
layer M-1:hidden
operations
layer M
existingoperations
newoperations :
:
OSes: 3. OS Structs 18
THETHE Layer Structure Layer Structure
layer 5: user programs
layer 4: buffering for I/O devices
layer 3: operator-console device drivers
layer 2: memory management
layer 1: CPU scheduling
layer 0: hardware
OSes: 3. OS Structs 19
5. Virtual Machines5. Virtual Machines
A A virtual machinevirtual machine supplies a set of ‘system’ supplies a set of ‘system’ calls that support a machine in softwarecalls that support a machine in software– it rests on top of the underlying physical it rests on top of the underlying physical
hardwarehardware
A virtual machine A virtual machine may bemay be different from the different from the underlying hardware.underlying hardware.
OSes: 3. OS Structs 20
IssuesIssues
The hardware places limits on the virtual The hardware places limits on the virtual machine’s functionalitymachine’s functionality– e.g. the number/type of peripheralse.g. the number/type of peripherals
How to support virtual user and monitor How to support virtual user and monitor modes in physical user mode?modes in physical user mode?
SpeedSpeed
OSes: 3. OS Structs 21
AdvantagesAdvantages
A virtual machine can protect physical A virtual machine can protect physical system resourcessystem resources
PortabilityPortability
Research/developmentResearch/development
OSes: 3. OS Structs 22
DisadvantagesDisadvantages
Difficult to implement a fast system.Difficult to implement a fast system.
Hard to support modes.Hard to support modes.
Speed issues may require simulation and/or Speed issues may require simulation and/or direct access to the underlying OS or hardwdirect access to the underlying OS or hardware.are.
OSes: 3. OS Structs 23
6. OS Design & Implementation6. OS Design & Implementation
6.1. Design Goals6.1. Design Goals– user and system design goals may conflictuser and system design goals may conflict
– goal tend to be vaguegoal tend to be vague e.g. easy to use, easy to implemente.g. easy to use, easy to implement
OSes: 3. OS Structs 24
6.2. Mechanisms & Policies6.2. Mechanisms & Policies
Separate policy from mechanismSeparate policy from mechanism– policy: what will be donepolicy: what will be done– mechanism: how to do itmechanism: how to do it
ExampleExample: CPU protection: CPU protection– mechanism: timermechanism: timer– policy: timer periodpolicy: timer period
FlexibilityFlexibility Micro-kernels vs. monolithsMicro-kernels vs. monoliths
OSes: 3. OS Structs 25
6.3. Implementation6.3. Implementation
Assembly language vs. high-level Assembly language vs. high-level languageslanguages
ExampleExample: UNIX is coded in C but for : UNIX is coded in C but for ~900 lines of assembler for the scheduler ~900 lines of assembler for the scheduler and device driversand device drivers