Title: Operating Systems
1OperatingSystems
CSCI-4210-01Spring 2009
- David Goldschmidt, Ph.D.
- Computer Science
- The College of Saint Rose
2ReviewInterrupt Mechanism
- Interrupts are handled much like calling a
function or method in a programming language
I/O devicestypically use abuffering strategy
3What is an Operating System?
- An Operating System is the software interface
between hardware and users - Operating systems
- Execute user and system programs
- Manage and coordinate computer hardware
- Use computer hardware efficiently
- Serve as resource allocators
- Are typically interrupt-driven
4Design Goals of an Operating System
- From a users perspective, an operating system
should be - easy to use
- easy to learn
- reliable
- safe
- fast
- System goals ofan operating system typically
include - reliability
- flexibility
- extensibility
- speed
- efficiency
- maintainability
5Functional Components
- Functional components of anoperating system
include - Process manager
- Memory manager
- Virtual memory manager
- File manager
- Device manager
6History of Operating Systems
- In the beginning
- the 1940s
ENIAC
7History of Operating Systems
- Automation in the 1950s using punch cards
8Batch Jobs
- A job is a unit of work submitted by a user
tothe operating system, typically consisting of - a program either in a sourcelanguage or in
binary form - a set of input data used bythe program when it
executes
9History of Operating Systems
- IBM 360 introduced
- in 1964
10Multiprogramming
11Multiprogramming
- In multiprogramming, several jobs reside in
memory simultaneously - CPU use is sharedand managed by theoperating
system
12Multiprogramming
- Multiprogramming provides efficient use of the
computer (CPU) and its resources (e.g. I/O) - One user cannot keep theCPU and I/O devices
busyat all times - Each running program iscalled a job
- Multiprogramming organizesjobs such that the CPU
alwayshas exactly one to execute
13Multiprogramming
- Computer is often idle why?
- CPU and hardware muchfaster than I/O
- When a user or process isblocked waiting for
I/O,the operating system switchesto another job - A subset of jobs is storedin memory, awaiting
CPUor other resources
14Timesharing (Multitasking)
- To ensure fairness, consider a timesharing scheme
in which the CPU cycles through all jobs - Each job (process) is givena fixed amount of CPU
time - Switching from one runningprocess to another is
calleda context switch - A process may relinquish itstime if blocked on
an I/O request
15Timesharing (Multitasking)
- Unless blocked on I/O, processes line
up,awaiting their turn with the CPU - CPU scheduling algorithmis necessary to
efficientlydecide the order in whichprocesses
execute - If processes do not fit intomemory, the
operating systemwill swap them in and out
ofmemory from virtual memory
16History of Operating Systems
- Personal computer revolution
- of the late 1970s and early 1980s
17History of Operating Systems
18History of Operating Systems
- World Wide Web and Internet revolution
- of the 1990s and early 2000s
19External View of a Computer
20Operating System Structure
- Using a layered approach, the operating system is
divided into N levels or layers - Layer 0 is the hardware
- Layer N is the top-leveluser interface
- Each layer uses functionsand services of lower
layers - Layer 1 often is the kernel
21Operating System Structure
22Operating System Kernel
- The core program running in anoperating system
is the kernel - When a computer is switched on,a bootstrap
program executes from ROM - Bootstrap program initializes all aspects of the
system, then loads the operating system kernel
and starts its execution
23User and Kernel Modes
- Dual-mode operation provides a user mode anda
kernel mode of operation - Allows the operating system to protect itself and
other system components
24User and Kernel Modes
- Kernel relinquishes control to a user
process,but may set a timer to ensure a process
does not run beyond its allotted time - Avoid infinite loops, memory leaks, memory hogs,
etc. - Not entirely effective in practice?
- How many times have you fought to stop a runaway
process?
- Kernel also provides securityvia privileged
instructions
25Operating System Services
- An operating system provides services to its
users - Program execution
- Load programs into memory, run/suspend/halt
programs, handle/display errors - I/O operations
- Seamlessly interact with I/O devices,
includingdisks, networks connection, etc. - Filesystem manipulation
- Read/write/traverse filesystem directories,read/w
rite files, enforce permissions, search for
files, etc.
26Operating System Services
- Other services an operating system provides
- Inter-Process Communications (IPC)
- Processes exchange information via shared
memory,message passing, sockets, pipes, files,
etc. - Might span multiple computer systems
- Error detection and recovery
- Errors arise in CPU, memory, I/O
devices,processes, etc. - Operating system should detect and recover from
errors, ensuring correct and consistent operations
27System Calls via APIs
- Operating system services available to usersvia
GUI and CLI, which are just software programs - System calls are made via programming
interfacecalled an Application Program Interface
(API) - Common operating system APIs
- Win32 API for Windows
- POSIX API for POSIX-based systems,including
UNIX, Linux, Mac OS X - Java API for Java Virtual Machine
- C Standard Library
28System Calls via APIs
- Types of system calls include
- Process control (e.g. start/suspend/stop a
process) - Debugging information, too
- File management
- Device management
- Information retrieval and maintenance
- Current date/time, number of current users, OS
version, amount of free memory, process
information, etc. - Communications (e.g. IPC, network)
29System Calls via APIs
- System call sequence for a file copy program
30System Calls via APIs
- The API successfully hides the implementation
detailsof the operating system - Programmer just needs to obeythe API
specifications - Change the operating system,but maintain the API
such thatit is backwards compatible - Deprecate old behavior over long period of time
31System Calls via APIs
32System Calls via APIs
- Example using theprintf() functionfrom C
33System Calls via APIs
- Pass parameters to the operating systemvia
registers or a block of data in memory
34Reading Assignments
- Read this week
- Chapters 1 and 2of the Garrido book