0% found this document useful (0 votes)
35 views17 pages

Unit-2 Os

Uploaded by

anchitaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views17 pages

Unit-2 Os

Uploaded by

anchitaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Operating System

UNIT 2 OVERVIEW OF OPERATING SYSTEMS

Introduction: Computer System Organization, Computer System Architecture, Operating System


Operations. Operating System Structure: OS Services, System calls, Types of System Calls,
Operating – System Structure, OS Generation and System Boot.

What is an Operating System


 An operating system is a program that manages the computer hardware. It also provides a
basis for application programs and acts as an intermediary between a user of a
computer and the computer hardware.
The purpose of an operating system is to provide an environment in which a user can execute
programs.
 Exploits the hardware resources of one or more processors (cores)
 Provides a set of services (system calls) to system users
 Manages main/secondary memory and I/O devices

Goals of an Operating System


 The primary goal of an operating system is thus to make the computer system convenient
to use.
 The secondary goal is to use the computer hardware in an efficient manner.

Components of a Computer System


A computer system can be divided roughly into four components.
i. Hardware
ii. Operating system
iii. The application programs
iv. Users

Computer System Organization


 Computer-system operation
 One or more CPUs, device controllers connect through common bus providing
access to shared memory
 Concurrent execution of CPUs and devices competing for memory cycles

1
Computer-System Operation
 I/O devices and the CPU can execute concurrently
 Each device controller is in charge of a particular device type
 Each device controller has a local buffer
 CPU moves data from/to main memory to/from local buffers
 I/O is from the device to local buffer of controller
 Device controller informs CPU that it has finished its operation by causing an interrupt

Common Functions of Interrupts


 Interrupt transfers control to the interrupt service routine generally, through the interrupt
vector, which 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:
 polling
 vectored interrupt system
 Separate segments of code determine what action should be taken for each type of interrupt
Interrupt Timeline

2
I/O Structure
 After I/O starts, control returns to user program only upon I/O completion
 Wait instruction idles the CPU until the next interrupt
 Wait loop (contention for memory access)
 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
 System call – request to the OS to allow user to wait for I/O completion
 Device-status table contains entry for each I/O device indicating its type, address,
and state
 OS indexes into I/O device table to determine device status and to modify table
entry to include interrupt
Storage Structure
 Main memory – only large storage media that the CPU can access directly
 Random access
 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
 Disk surface is logically divided into tracks, which are subdivided into sectors
 The disk controller determines the logical interaction between the device and
the computer
 Solid-state disks – faster than hard disks, nonvolatile
 Various technologies
 Becoming more popular
Storage Hierarchy
 Storage systems organized in hierarchy
3
 Speed
 Cost
 Volatility
 Caching – copying information into faster storage system; main memory can be viewed as
a cache for secondary storage
 Device Driver for each device controller to manage I/O
 Provides uniform interface between controller and kernel
Storage-Device Hierarchy

Caching
 Important principle, performed at many levels in a computer (in hardware, operating
system, software)
 Information in use copied from slower to faster storage temporarily
 Faster storage (cache) checked first to determine if information is there
 If it is, information used directly from the cache (fast)
 If not, data copied to cache and used there
 Cache smaller than storage being cached
 Cache management important design problem
 Cache size and replacement policy
Direct Memory Access Structure
 Used for high-speed I/O devices able to transmit information at close to memory speeds
 Device controller transfers blocks of data from buffer storage directly to main memory
without CPU intervention
 Only one interrupt is generated per block, rather than the one interrupt per byte
4
How a Modern Computer Works

Computer-System Architecture
 Most systems use a single general-purpose processor
o Most systems have special-purpose processors as well
 Multiprocessors systems growing in use and importance
o Also known as parallel systems, tightly-coupled systems
o Advantages include:
 Increased throughput
 Economy of scale
 Increased reliability – graceful degradation or fault tolerance
o Two types:
 Asymmetric Multiprocessing – each processor is assigned a specie task.
 Symmetric Multiprocessing – each processor performs all tasks
Symmetric Multiprocessing Architecture

A Dual-Core Design

5
o Multi-chip and multicore
o Systems containing all chips
 Chassis containing multiple separate systems

Clustered Systems
 Like multiprocessor systems, but multiple systems working together
o Usually sharing storage via a storage-area network (SAN)
o Provides a high-availability service which survives failures
 Asymmetric clustering has one machine in hot-standby mode
 Symmetric clustering has multiple nodes running applications, monitoring
each other
o Some clusters are for high-performance computing (HPC)
 Applications must be written to use parallelization
o Some have distributed lock manager (DLM) to avoid conflicting operations

Operating-System Operations
 Interrupt driven (hardware and software)
 Hardware interrupt by one of the devices
 Software interrupt (exception or trap):
 Software error (e.g., division by zero)
6
 Request for operating system service
 Other process problems include infinite loop, processes modifying each
other or the operating system
 Dual-mode operation allows OS to protect itself and other system components
 User mode and kernel mode
 Mode bit provided by hardware
 Provides ability to distinguish when system is running user code or kernel
code
 Some instructions designated as privileged, only executable in kernel mode
 System call changes mode to kernel, return from call resets it to user
 Increasingly CPUs support multi-mode operations
 i.e. virtual machine manager (VMM) mode for guest VMs
Transition from User to Kernel Mode
 Timer to prevent infinite loop / process hogging resources
 Timer is set to interrupt the computer after some time period
 Keep a counter that is decremented by the physical clock.
 Operating system set the counter (privileged instruction)
 When counter zero generate an interrupt
 Set up before scheduling process to regain control or terminate program that
exceeds allotted time

Operating System Services


 Operating systems provide an environment for execution of programs and services to
programs and users
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)

7
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
(packets moved by the OS)
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
 Debugging facilities can greatly enhance the user’s and programmer’s
abilities to efficiently use the system
o Resource allocation - When multiple users or multiple jobs running concurrently,
resources must be allocated to each of them
o 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
o Protection and security - The owners of information stored in a multiuser or
networked computer system may want to control use of that information,
concurrent processes should not interfere with each other
o Protection involves ensuring that all access to system resources is controlled
o Security of the system from outsiders requires user authentication, extends to
defending external I/O devices from invalid access attempts
A View of Operating System Services

8
SYSTEM CALLS
 System provides interface between the process & the OS.
 The calls are generally available as assembly language instruction & certain system allow system
calls to be made directly from a high level language program.
 Several language have been defined to replace assembly language program.
 A system call instruction generates an interrupt and allows OS to gain control of the processors.
PASSING PARAMETERS TO OS

Three general methods are used to pass the parameters to the OS.

 The simplest approach is to pass the parameters in registers. In some there can be more
parameters than register. In these the parameters are generally in a block or table in m/y
and the address of the block is passed as parameters in register. This approach used by
Linux.
 Parameters can also be placed or pushed onto stack by the program & popped off the
stack by the OS.
 Some OS prefer the block or stack methods, because those approaches do not limit the
number or length of parameters being passed.
 System calls may be grouped roughly into 5 categories
1. Process control.
2. File management.
3. Device management.
4. Information maintenance.
5. Communication.
 Process control
o create process, terminate process
o end, abort
9
o load, execute
o get process attributes, set process attributes
o wait for time
o wait event, signal event
o allocate and free memory
o Dump memory if error
o Debugger for determining bugs, single step execution
o Locks for managing access to shared data between processes
 File management
o create file, delete file
o open, close file
o read, write, reposition
o get and set file attributes
 Device management
o request device, release device
o read, write, reposition
o get device attributes, set device attributes
o logically attach or detach devices
 Information maintenance
o get time or date, set time or date
o get system data, set system data
o get and set process, file, or device attributes
 Communications
o create, delete communication connection
o send, receive messages if message passing model to host name or process name
 From client to server
o Shared-memory model create and gain access to memory regions
o transfer status information
o attach and detach remote devices
 Protection
o Control access to resources
o Get and set permissions
o Allow and deny user access
Examples of Windows and Unix System Calls

10
program invoking printf() library call, which calls write() system call

Operating System Structure


 General-purpose OS is very large program
11
 Various ways to structure ones
o Simple structure – MS-DOS
o More complex -- UNIX
o Layered – an abstrcation
o Microkernel -Mach
Simple Structure -- MS-DOS
 MS-DOS – written to provide the most functionality in the least space
o Not divided into modules
o Although MS-DOS has some structure, its interfaces and levels of functionality are
not well separated

Non Simple Structure -- UNIX

 UNIX – limited by hardware functionality, the original UNIX operating system had
limited structuring. The UNIX OS consists of two separable parts
o Systems programs
o The kernel
 Consists of everything below the system-call interface and above the
physical hardware
 Provides the file system, CPU scheduling, memory management, and other
operating-system functions; a large number of functions for one level
Traditional UNIX System Structure

12
Layered Approach
 The operating system is divided into a number of layers (levels), each built on top of lower
layers. The bottom layer (layer 0), is the hardware; the highest (layer N) is the user
interface.
 With modularity, layers are selected such that each uses functions (operations) and services
of only lower-level layers
Microkernel System Structure
 Moves as much from the kernel into user space
 Mach example of microkernel
o Mac OS X kernel (Darwin) partly based on Mach
 Communication takes place between user modules using message passing
 Benefits:
o Easier to extend a microkernel
o Easier to port the operating system to new architectures
o More reliable (less code is running in kernel mode)
o More secure
 Detriments:
o Performance overhead of user space to kernel space communication

Modules
13
 Many modern operating systems implement loadable kernel modules
o Uses object-oriented approach
o Each core component is separate
o Each talks to the others over known interfaces
o Each is loadable as needed within the kernel
 Overall, similar to layers but with more flexible
o Linux, Solaris, etc
Solaris Modular Approach

Hybrid Systems
 Most modern operating systems are actually not one pure model
o Hybrid combines multiple approaches to address performance, security, usability
needs
o Linux and Solaris kernels in kernel address space, so monolithic, plus modular for
dynamic loading of functionality
o Windows mostly monolithic, plus microkernel for different subsystem
personalities
 Apple Mac OS X hybrid, layered, Aqua UI plus Cocoa programming environment
o Below is kernel consisting of Mach microkernel and BSD Unix parts, plus I/O kit
and dynamically loadable modules (called kernel extensions)
Mac OS X Structure

14
iOS
 Apple mobile OS for iPhone, iPad
o Structured on Mac OS X, added functionality
o Does not run OS X applications natively
 Also runs on different CPU architecture (ARM vs. Intel)
o Cocoa Touch Objective-C API for developing apps
o Media services layer for graphics, audio, video
o Core services provides cloud computing, databases
o Core operating system, based on Mac OS X kernel

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
 Java class files compiled to Java bytecode then translated to executable than
runs in Dalvik VM
15
 Libraries include frameworks for web browser (webkit), database (SQLite), multimedia,
smaller libc
Android Architecture

Operating System Generation


 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
 Used to build system-specific compiled kernel or system-tuned
 Can general more efficient code than one general kernel
 The following kinds of information must be determined.
 What CPU is to be used? What options (extended instruction sets, floating point
arithmetic, and so on) are installed? For multiple CPU systems, each CPU may be
described.
 How will the boot disk be formatted? How many sections, or “partitions,” swill it
be separated into, and what will go into each partition?
 How much memory is available? Some systems will determine this value
themselves by referencing memory location after memory location until an “illegal
address” fault is generated. This procedure defines the final legal address and hence
the amount of available memory.
 What devices are available? The system will need to know how to address each
device (the device number), the device interrupt number, the device’s type and model, and any
special device characteristics.

16
 What operating-system options are desired, or what parameter values are to be
used? These options or values might include how many buffers of which sizes should be used,
what type of CPU-scheduling algorithm is desired, what the maximum number of processes to
be supported is, and so on.

System Boot
 When power initialized on system, execution starts at a fixed memory location
o Firmware ROM used to hold initial boot code
 Operating system must be made available to hardware so hardware can start it
o Small piece of code – bootstrap loader, stored in ROM or EEPROM locates the
kernel, loads it into memory, and starts it
o Sometimes two-step process where boot block at fixed location loaded by ROM
code, which loads bootstrap loader from disk
 Common bootstrap loader, GRUB, allows selection of kernel from multiple disks,
versions, kernel options
 Kernel loads and system is then running

17

You might also like