Operating Systems
Operating Systems
1. Operating System
A program that acts as an intermediary between a user of a computer and the computer
hardware
Operating system goals:
o Execute user programs and make solving user problems easier
o Make the computer system convenient to use
o Use the computer hardware in an efficient manner
Operating System Definition:
OS is a resource allocator
Manages all resources
Decides between conflicting requests for efficient and fair resource use
OS is a control program
Controls execution of programs to prevent errors and improper use of the
computer
Bootstrap Program
Computer-System Operation
Two types:
Eg:-Device controller informs CPU that it has finished its operation by causing an
interrupt
Interrupt transfers control to the interrupt service routine through the interruptvector
Interrupt vector contains the addresses of all the service routines
Interrupt architecture must save the address of the interrupted instruction
A trap or exception is a software-generated interrupt caused either by an error or a
user request
An operating system is interrupt driven
Interrupt Handling
The operating system preserves the state of the CPU by storing registers and the program
counter
Determines which type of interrupt has occurred:
o Polling - CPU keeps on checking I/O devices at regular interval whether it needs
CPU service
o vectored interrupt system - the I/O device interrupts the CPU and tell CPU that it
need CPU service
Separate segments of code determine what action should be taken for each type of
interrupt
Interrupt Timeline
5. I/O Structure
After I/O starts, control returns to user program only upon I/O completion
o Wait instruction idles the CPU until the next interrupt
o Wait loop (contention for memory access)
o At most one I/O request is outstanding at a time, no simultaneous I/O processing
After I/O starts, control returns to user program without waiting for I/O completion
o System call – request to the OS to allow user to wait for I/O completion
o Device-status table contains entry for each I/O device indicating its type,
address, and state
o OS indexes into I/O device table to determine device status and to modify table
entry to include interrupt
6. Storage Structure
Main memory – only large storage media that the CPU can access directly
o Randomaccess
o Typically volatile
Secondary storage – extension of main memory that provides large nonvolatile storage
capacity
Hard disks – rigid metal or glass platters covered with magnetic recording material
o Disk surface is logically divided into tracks, which are subdivided into sectors
o The disk controller determines the logical interaction between the device and the
computer
Caching
The device controller transfers an entire block of data directly to or from its own buffer
storage to memory, with no intervention by the CPU.
Only one interrupt is generated per block, to tell the device driver that the operation has
completed, rather than the one interrupt per byte generated for low-speed devices.
While the device controller is performing these operations, the CPU is available to
accomplish other work.
Some high-end systems use switch rather than bus architecture. On these systems,
multiple components can talk to other components concurrently, rather than competing
for cycles on a shared bus. In this case, DMA is even more effective.
Advantages
Increased throughput
By increasing the number of processors, we expect to get more work
done in less time.
Economy of scale
Multiprocessor systems can cost less than equivalent multiple single-
processor systems,because they can share peripherals, mass storage, and
power supplies.
Increased reliability – graceful degradation or fault tolerance
If we have ten processors and one fails, then each of the remaining nine
processors can pick up a share of the work of the failed processor. Thus,
the entire system runs only 10 percent slower, rather than failing
altogether.
o Two types:
Asymmetric Multiprocessing
Each processor is assigned a specie task.
A boss processor controls the system; the other processors either look to
the boss for instruction or have predefined tasks.
This scheme defines a boss–worker relationship.
The boss processor schedules and allocates work to the worker
processors.
Symmetric Multiprocessing
Each processor performs all tasks
SMP means that all processors are peers; no boss–worker relationship
exists between processors.
The following example shows the symmetric multiprocessing architecture
iii)Dual-Core Design
In response to the need for more computing performance, single-CPU systems evolved
into multi-CPU systems.
A more recent, in system design is to place multiple computing cores on a single chip.
Each core appears as a separate processor to the operating system.
Whether the cores appear across CPU chips or within CPU chips, we call these systems
multicore or multiprocessor systems
Jobs are submitted on cards or tape to an operator who batches jobs together sequentially
New Features:
Memory Management: - to have several jobs ready to run, they must be kept in
main memory
Multiprogramming Systems :
Several Programs use the Computer System
Time-Sharing systems :
Several (human) users use the computer system interactively
Characteristics:
Using multiprogramming to handle multiple interactive jobs
Processor’s time is shared among multiple users
Multiple users simultaneously access the system through terminals
One set of operating-system services provides functions that are helpful to the user:
o User interface - Almost all operating systems have a user interface (UI).
Varies between Command-Line (CLI), Graphics User Interface (GUI),
Batch
o 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)
o I/O operations - A running program may require I/O, which may involve a file
or an I/O device
o File-system manipulation- The file system is of particular interest. Programs
need to read and write files and directories, create and delete them, search them,
list file Information, permission management.
o Communications – Processes may exchange information, on the same computer
or between computers over a network
Communications may be via shared memory or through message passing
o Error detection – OS needs to be constantly aware of possible errors
May occur in the CPU and memory hardware, in I/O devices, in user
program
For each type of error, OS should take the appropriate action to ensure
correct and consistent computing
Many types of resources - CPU cycles, main memory, file storage, I/O
devices.
o Accounting - To keep track of which users use how much and what kinds of
computer resources
System Programs
Layered Approach
4. Microkernel System Structure
o Moves as much from the kernel into user space
o Mach example of microkernel
Mac OS X kernel (Darwin) partly based on Mach
o Communication takes place between user modules using message passing
o Benefits:
Easier to extend a microkernel
Easier to port the operating system to new architectures
More reliable (less code is running in kernel mode)
More secure
iOS
8. Android
Developed by Open Handset Alliance (mostly Google)
o Open Source
Similar stack to iOS
Based on Linux kernel but modified
o Provides process, memory, device-driver management
o Adds power management
Runtime environment includes core set of libraries and Dalvik virtual machine
o Apps developed in Java plus Android API
Libraries include frameworks for
o web browser (webkit),
o database (SQLite),
o Multimedia and smaller libc
Android Architecture
Operating systems are designed to run on any of a class of machines; the system must be
configured for each specific computer site
SYSGEN program obtains information concerning the specific configuration of the
hardware system
o Used to build system-specific compiled kernel or system-tuned
System Boot
o Initialization data
o Keeping track of which parts of memory are currently being used and by
whom
o Deciding which processes (or parts thereof) and data to move into and out of
memory
o Allocating and deallocating memory space as needed
3. Storage Management
OS provides uniform, logical view of information storage
o Abstracts physical properties to logical storage unit - file
o Each medium is controlled by device (i.e., disk drive, tape drive)
properties include access speed, capacity, data-transfer rate, access
method (sequential or random)
4. File-System management
o Files usually organized into directories
o Access control on most systems to determine who can access what
OS activities
OS activities
o Free-space management
o Storage allocation
o Disk scheduling
6. I/O Subsystem
One purpose of OS is to hide peculiarities of hardware devices from the user
I/O subsystem responsible for
o Memory management of I/O including
buffering (storing data temporarily while it is being transferred),
caching (storing parts of data in faster storage for performance),
spooling (the overlapping of output of one job with input of other jobs)
o General device-driver interface
o Drivers for specific hardware devices
7. Protection and Security
Protection– any mechanism for controlling access of processes or users to resources
defined by the OS
Security – defense of the system against internal and external attacks
Huge range, including denial-of-service, worms, viruses, identity theft, theft of
service