Slide 1
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
CECS 326
• Professor: Mr. Ratana Ngo• Textbook
• Title: Operating Systems, 3rd edition• Author: Gary Nutt• ISBN: 0-201-77344-9
• Assignments and Grading• Programs and homework packets: 25%• Quizzes and Exams: 50%• Final exam: 25%
Purpose and Benefits1. Sharing computing resources
2. Management of computing resources
• CPU, memory, other devices, and software
3. Speed of computation
4. Uniformity and portability• Hardware interface• Software interface
5. Mask system complexity
6. Internetworking
7. Protection, security, and reliability
Slide 4
Copyright © 2004 Pearson Education, Inc.
System Software
(revised) -- Operating Systems: A Modern Perspective, Chapter 1
LoaderLoader
OSOSDatabaseManagement
System
DatabaseManagement
System
WindowSystem
WindowSystem
ApplicationProgrammer
Syst
em S
oft w
are
LibrariesLibrariesCompilerCompiler
Hardware
CommandLine
Interpreter
CommandLine
Interpreter
LibrariesLibraries
Software APISoftware API
Slide 5
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
Sharing a CPU
• Efficiency: time multiplexing the CPU enables more than one application and more than one user to use the computer system
• Throughput: multiprogramming reduces the time to execute all computing tasks
• Responsiveness: multiprogramming minimizes computational delay
• Multi-tasking raises productivity• Multi-threading improves software
Slide 6
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
Time and space multiplexing
Using the processor
I/O operation
Time
Process 1
Process 2
Process 3
Process 4
Space-multiplexed Memory
Time-multiplexed CPU
Some considerationsCPU versus I/O (using rough estimates)
• CPU clock: 1 GHz (or 1 nsec/cycle)
• Keyboard: 100 wpm < 3000 char/min < 1 char/sec (or 1000 msec per char)
• Hard disk operation: 10 msec
Conclusion: I/O bound processes – User takes hundreds ofseconds to enter some data, CPU uses nanoseconds to process it. More than 90% of CPU capacity is wasted.
Question: Why are users obsessed with faster CPU?
Homework: Consider a DSL line at 1 Mbps! Estimate thedifference in speed. Where is the bottleneck?
Slide 8
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
Supporting multiprogramming
OS features needed for multiprogramming:
• Interface with input/output devices• Management of devices• Memory management• CPU scheduling
Slide 9
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
2
Using the operating system
Slide 10
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
Client-server example
(server)
loop forever
listen for client connection
spawn new child server
pass connection to child
endloop
Slide 11
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
The Shell Strategy
Shell ProcessShell Process
Processto executecommand
Processto executecommand
% grep first f3
f3
read keyboard fork a process
read file
Slide 12
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
OS Design Constraints
• Performance
• reliability
• Protection and security
• Correctness
• Maintainability
• Commercial factors
• Standards and open systems
Slide 13
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
Reliability
Hardware Resources
OS
OS Resources (OS Interface)
Middleware
Abstract Resources (API)
Application
User Interface
save
coutfwrite
write
layout view
Slide 14
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
Performance
• The OS is an overhead function ⇒ should not use too much of machine’s resources
• Minimum functionality is to implement generic services
• Additional function must be traded off against performance– DOS: single process– UNIX: command line interface and “stream of
bytes”
Slide 15
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
OS services• Program execution – system capability to load a
program and to run it• I/O operations – user programs are not allowed to
execute I/O operations directly; hence, the OS must provide some means to use I/O devices
• File system manipulation – program capability to read, write, create, and delete files
• Communications – exchange of information between processes executing either on the same computer or on different systems connected together by a network
Slide 16
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
OS services• Error detection – ensure correct computing by
detecting errors in the CPU and memory hardware, I/O devices, or in user programs
• Additionally:– Resource allocation – allocating resources to
multiple users or multiple jobs executing concurrently
– Accounting – keep track of and record which users use how much and what kinds of computer resources
– Protection – ensuring that all access to system resources is controlled
Slide 17
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
System calls
• A system call is an OS function provided by the operating system
• Applications use system calls to interface/request services from the OS
• Abstract all devices to a few interfaces: read, write, seek, ioctl, etc.
• Benefits: security, reliability, stability, uniformity/portability
Slide 18
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
System calls
• Process control – create, terminate, load, execute, allocate/deallocate memory, suspend, resume, etc.
• Device management – request, release, read, write, seek, mount/unmount, get/set attributes
• File management – create, delete, open, close, read, write, seek, get/set attributes
• Networking/communications – create/delete resources, send/receive data, attach/detach resources
• Information maintenance – get/set time/date, get/set system data, get/set process/file/device attribute, etc.
Slide 19
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
Common OS components
• Process management• Main memory management• Secondary management• File management• Device management• Networking/communications• Protection and security
Slide 20
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
Process management - overview
• A process is a program in execution. A process needs resources: CPU time, memory, files, I/O devices, etc. to complete its task.
• The OS is responsible for:– Process creation and deletion– Process suspension and resumption– Mechanism for
• Process synchronism• Process communication
Slide 21
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
Main memory management - overview
• Memory is a large array of bytes/words, each with its own address. It stores data shared by the CPU and I/O devices.
• Main memory is volatile.• The OS is responsible for:
– 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
Slide 22
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
Secondary storage management - overview
• Since main memory is too small to accommodate all data and programs, the computer system provides secondary storage to back up main memory
• Modern computer systems use disks as primary on-line storage medium of data and programs
• The OS is responsible for:– Free space management– Storage allocation– Disk scheduling
Slide 23
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
File management - overview
• A file is a collection of related information defined by its creator. Commonly, files represent programs (both source and object forms) and data.
• The OS is responsible for:– File creation and deletion– Directory creation and deletion– Support of primitives for manipulating files and
directories– Mapping files onto secondary storage– File backup on stable storage media
Slide 24
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
Device management - overview
• The OS abstracts devices to a few common interfaces (see system calls)
• The I/O device system consists of:– Device allocation– Data buffering– Data caching– Device drivers
Slide 25
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
Networking/communications - overview
• A distributed system is a collection of processors that do not share memory or a clock.
• The computers in the system are connected through a communication network
• Communication takes place via a protocol• A distributed system provides users access to
various resources– Computational speed up– Increased data availability– Enhanced reliability
Slide 26
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
Protection and security - overview
• Protecting directory and file, CPU, I/O devices, memory, etc.
• Protection refers to a mechanism for controlling access by programs, processes, or users to both system and user resources
• The protection mechanism must:– Distinguish between authorized and unauthorized usage– Specify the controls to be imposed– Provide a means of enforcement
• Security policy defines strategies for sharing resources and is separate from mechanism
Slide 27
Copyright © 2004 Pearson Education, Inc.
Basic Operating System Organization
(revised) -- Operating Systems: A Modern Perspective, Chapter 1
Processor(s) Main Memory Devices
Process, Thread &Resource Manager
MemoryManager
DeviceManager
FileManager
Slide 28
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
CPU Modes
• Mode bit: Supervisor/monitor or User mode
• Supervisor mode– Can execute all machine instructions– Can reference all memory locations
• User mode– Can only execute a subset of instructions– Can only reference a subset of memory
locations
Slide 29
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
Kernels
• The critical part of the OS • trusted code that executes without any
constraints• essential that the kernel is correct• Executes in supervisor mode
Slide 30
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
LibrariesLibraries CommandsCommands
Device DriverDevice Driver
The UNIX ArchitectureInteractive User
ApplicationPrograms
ApplicationPrograms
OS System Call Interface
Device DriverDevice Driver
Device DriverDevice Driver
Dri
ver
Inte
rfac
eD
rive
r In
terf
ace
…Monolithic Kernel Module•Process Management•Memory Management•File Management•Device Mgmt Infrastructure
Trap Table
…
Slide 31
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
Linux architecture
• monolithic design to minimize the overhead of message passing• Linux kernel services include: CPU scheduling, process management,
memory management, interprocess communication
• loadable kernel modules can be loaded or unloaded as needed. these modules include file systems, device drivers, networking, etc.
• non-kernel OS services are implemented as system library functions
Slide 32
Copyright © 2004 Pearson Education, Inc.
Microkernel Organization
(revised) -- Operating Systems: A Modern Perspective, Chapter 1
Device managerDevice managerMicrokernelMicrokernel
Processor(s) Main Memory Devices
LibrariesLibraries
ProcessProcess
ProcessProcess
ProcessProcess
File systemFile system SchedulerScheduler NetworkingNetworking
User
Supervisor
Slide 33
Copyright © 2004 Pearson Education, Inc.
Windows NT Organization
(revised) -- Operating Systems: A Modern Perspective, Chapter 1
Processor(s) Main Memory Devices
LibrariesLibraries
ProcessProcess
ProcessProcess
ProcessProcess
SubsystemSubsystemUser
Supervisor
SubsystemSubsystem SubsystemSubsystem
Hardware Abstraction LayerHardware Abstraction LayerNT Kernel
NT ExecutiveI/O SubsystemI/O Subsystem
TT
TT
TT T T
T
Process ManagementMemory ManagementFile ManagementDevice Mgmt Infrastructure
Slide 34
Copyright © 2004 Pearson Education, Inc.(revised) -- Operating Systems: A Modern Perspective, Chapter 1
Virtual Machines
• Each virtual machine is isolated from all other virtual machines • CPU scheduling can create the appearance that users have their
own processor• Spooling and a file system can provide virtual card readers and
virtual line printers
• A normal user time sharing terminal servers as the virtual machine operator’s console