1 introduction

38
Introduction to OS What Operating Systems Do? Computer-System Organization Computer-System Architecture Operating-System Structure Operating-System Operations Process Management Process Management Memory Management Storage Management Protection and Security Distributed Systems Special-Purpose Systems Computing Environments Loganathan R, CSE,HKBKCE 1

description

Introduction to Operating Systems

Transcript of 1 introduction

Page 1: 1 introduction

Introduction to OS

• What Operating Systems Do?

• Computer-System Organization

• Computer-System Architecture

• Operating-System Structure

• Operating-System Operations

• Process Management• Process Management

• Memory Management

• Storage Management

• Protection and Security

• Distributed Systems

• Special-Purpose Systems

• Computing Environments

Loganathan R, CSE,HKBKCE 1

Page 2: 1 introduction

1. What Operating System Do

• Computer system can be divided into four components– Hardware – provides basic computing resources

• CPU, memory, I/O devices

– Operating system

• Controls and coordinates use of hardware among variousapplications and usersapplications and users

– Application programs – define the ways in which the systemresources are used to solve the computing problems of the users.Word processors, compilers, web browsers, database systems, videogames

– Users

• People, machines, other computers

Loganathan R, CSE,HKBKCE 2

Page 3: 1 introduction

Components of a Computer System

Loganathan R, CSE,HKBKCE 3

Page 4: 1 introduction

OS Role from 2 Viewpoints• 1.1 User View

• Varies according to the Inter Face Used• Single User I/F: Ease of Use• Terminal User I/F: Resource(shared) Utilization• Workstation User I/F: Dedicated & Shared Resource• Handheld System User I/F : Individual Usability• Embedded Computers : Little/No user view

• 1.2 System View• 1.2 System View– OS is a resource allocator

–Manages all resources (CPU time, memory space, file-storage space, I/O devices)

–Decides between conflicting requests for efficient and fair resource use– OS is a control program

–Manages the execution of user programs to prevent errors andimproper use of the computer–Concerned with the operation and control of I/O devices.

Loganathan R, CSE,HKBKCE 4

Page 5: 1 introduction

1.3. OS Definition

No universally accepted definition

• An operating system is a program that manages thecomputer hardware, provides a basis for applicationprograms and acts as an intermediary between thecomputer user and the computer hardware

“Everything a vendor ships when you order an “Everything a vendor ships when you order anoperating system” is good approximation◦ But varies wildly

“The one program running at all times on thecomputer” is the kernel. Everything else is either asystem program (ships with the operating system) oran application program

Loganathan R, CSE,HKBKCE 5

Page 6: 1 introduction

2. Computer System Organization• 2.1 Computer System Operation

– One or more CPUs, device controllers connect through common busproviding access to shared memory

– Concurrent execution of CPUs and devices competing for memorycycles

– During Power up/ Reboot, it needs to have a initial program to runcalled Bootstrap Program

Loganathan R, CSE,HKBKCE 6

Page 7: 1 introduction

Bootstrap Program Typically stored in ROM or EPROM, generally known as firmware

Initializes all aspects of the system from CPU registers to device controllersto memory contents

Loads operating system kernel and starts execution and waits for an Event

• An event is usually signaled by an interrupt from either the hardware orthe software

• Hardware may trigger an interrupt at any time by sending a signal to the• Hardware may trigger an interrupt at any time by sending a signal to theCPU

• Software may trigger an interrupt by executing a special operation called asystem call (also called a monitor call)

Loganathan R, CSE,HKBKCE 7

Page 8: 1 introduction

Functions of Interrupts When interrupted, CPU stops what it is doing and immediately

transfers execution to a fixed location, which contains the startingaddress where the service routine for the interrupt is located

• The interrupt service routine executes, on completion, the CPUresumes the interrupted computation.

• A time line of this operation is shown

Loganathan R, CSE,HKBKCE 8

Page 9: 1 introduction

Interrupt Handling• Table of pointers is stored in low memory locations hold the addresses

of the interrupt service routines for the various devices.

• This array, or interrupt vector, of addresses is then indexed by a uniquedevice number, given with the interrupt request, to provide the addressof the interrupt service routine for the interrupting device

Interrupt architecture must save the address of the interruptedinstruction on the system stack.

After the interrupt is serviced, the saved return address is loaded into• After the interrupt is serviced, the saved return address is loaded intothe program counter, and the interrupted computation resumes asthough the interrupt had not occurred

A trap is a software-generated interrupt caused either by an error or auser request.

An operating system is interrupt driven.

Loganathan R, CSE,HKBKCE 9

Page 10: 1 introduction

2.2 Storage Structure• Computer programs to be executed must be in main memory RAM,

Which is the only large storage area that the CPU can access directly• It is implemented in a semiconductor technology called dynamic

random-access memory (DRAM)• Each word has its own address & interaction is through a load or store

instructions• A typical instruction-execution cycle, fetches an instruction from

memory and stores in the instruction register, then decoded and maycause operands to be fetched from memory and has been executed,the result may be stored back in memorythe result may be stored back in memory

• To reside the programs and data in main memory permanently is notpossible for the following two reasons:– 1. Main memory is usually too small to store all needed programs and data

permanently.– 2. Main memory is a volatile storage device that loses its contents when

power is turned off or otherwise lost

Secondary storage(Magnetic disks, CD-ROM, Magnetic tapes) – isextension of main memory that provides large nonvolatile storagecapacity.

Loganathan R, CSE,HKBKCE 10

Page 11: 1 introduction

Storage-Device Hierarchy

Storage systems organized in hierarchy according tospeed, cost and volatility

Volatile

Loganathan R, CSE,HKBKCE 11

Nonvolatile

Page 12: 1 introduction

2.3 I/O Structure• A general-purpose computer system consists of CPUs and

multiple device controllers that are connected through acommon bus.

• Depending on the controller, there may be more than oneattached device SCSI -8

• The device controller is responsible for moving the databetween the peripheral devices that it controls and its localbetween the peripheral devices that it controls and its localbuffer storage

• device driver for each device controller presents a uniforminterface to the device to the rest of the operating system

Loganathan R, CSE,HKBKCE 12

Page 13: 1 introduction

I/O operation• Interrupt-driven I/O

– For moving small amount of data– The device controller, examines the contents of the registers to

determine what action to take.– The controller starts the transfer of data from the device to its

local buffer– Once the transfer of data is complete, the device controller

informs the device driver via an interrupt that it has finished itsoperationinforms the device driver via an interrupt that it has finished itsoperation

Direct memory access– For bulk data movement such as disk I/O– After setting up buffers, pointers, and counters for the I/O

device, the device controller transfers an entire block of datadirectly to or from its own buffer storage to memory, with nointervention by the CPU

– Only one interrupt is generated per block, rather than the oneinterrupt per byte.

Loganathan R, CSE,HKBKCE 13

Page 14: 1 introduction

Direct memory access

Loganathan R, CSE,HKBKCE 14

Page 15: 1 introduction

3. Computer-System Architecture• 3.1 Single-Processor Systems

– Most systems are single processor and range from PDAsthrough mainframes

– One main CPU capable of executing a general-purposeinstruction set

– Special-purpose processors are device-specific processors,such as disk, keyboard, and graphics controllers withsuch as disk, keyboard, and graphics controllers withLimited Instruction Set

– Example:• PCs contain a microprocessor in the keyboard to convert the

keystrokes into codes to be sent to the CPU

– If there is only one general-purpose CPU, then the system isa single-processor system.

Loganathan R, CSE,HKBKCE 15

Page 16: 1 introduction

3.2 Multiprocessor Systems• Multiprocessor systems also known as parallel systems or

tightly coupled systems have two or more processors in closecommunication, sharing the computer bus and sometimes theclock, memory, and peripheral devices

• Advantages

– 1. Increased throughput: speed-up ratio with N processors is less than– 1. Increased throughput: speed-up ratio with N processors is less than

N due to overhead in keeping all the parts working

– 2. Economy of scale : Multiprocessor systems can cost less than

equivalent multiple single-processor systems, because they can shareperipherals, mass storage, and power supplies

– 3. Increased reliability :The failure of one processor will not halt the

system

Loganathan R, CSE,HKBKCE 16

Page 17: 1 introduction

Reliability

• The ability to continue providing serviceproportional to the level of surviving hardware iscalled graceful degradation

• Some systems go beyond graceful degradation andare called fault tolerant, because they can suffer afailure of any single component and still continuefailure of any single component and still continueoperation

• Fault tolerance requires a mechanism to allow thefailure to be detected, diagnosed, and, if possible,corrected

Loganathan R, CSE,HKBKCE 17

Page 18: 1 introduction

Types of Multiprocessor Systems• Asymmetric multiprocessing

– A master processor controls the system; the other processorseither look to the master for instruction or have predefinedtasks

– The master processor schedules and allocates work to the slaveprocessors

• Symmetric multiprocessing (SMP)• Symmetric multiprocessing (SMP)– Each processor performs all tasks within the operating system,

all processors are peers

– SMP architecture:

Loganathan R, CSE,HKBKCE 18

Page 19: 1 introduction

Types of Multiprocessor Systems• Multiple cores

– Multiple compute cores on a single chip

– Multi-core CPUs look to the OS just as N standard processors

• Blade servers– Multiple processor boards, I/O boards, and networking boards are

placed in the same chassis

– Each blade-processor board boots independently and runs its own OS

• Difference between SMP and asymmetricmultiprocessing

– Special hardware can differentiate the multiple processors,or the software can be written to allow only one masterand multiple slaves

Loganathan R, CSE,HKBKCE 19

Page 20: 1 introduction

3.3 Clustered Systems• Gather together multiple CPUs to accomplish computational work

• Composed of two or more individual systems coupled together

• Accepted definition

– Clustered computers share storage and are closely linked via a local-areanetwork (LAN) or a faster interconnect such as InfiniBand

• provides high-availability service through a level of redundancy

• Asymmetric clustering, one machine is in hot-standby mode while theother is running the applicationsother is running the applications

• Symmetric mode, two or more hosts are running applications, and aremonitoring each other

• Parallel clusters and clustering over a wide-area network (WAN) allowmultiple hosts to access the same data on the shared storage, to providethis, the system needs an access control and locking to ensure that noconflicting operations occur and this function is known as distributed lockmanager (DLM)

• Storage-area networks (SANs), which allow many systems to attach to apool of storage

Loganathan R, CSE,HKBKCE 20

Page 21: 1 introduction

4. Operating System Structure Single user cannot keep CPU and I/O

devices busy at all times

• Multiprogramming needed forefficiency

– Multiprogramming organizes jobs(code and data) so CPU always hasone to executeone to execute

– A subset of total jobs in system iskept in memory

– One job selected and run via jobscheduling

– When it has to wait (for I/O forexample), OS switches to another job

Loganathan R, CSE,HKBKCE 21

Page 22: 1 introduction

Operating System Structure contd..

• Timesharing / Multitasking in which CPU switches jobs sofrequently that users can interact with each job while it isrunning, creating interactive computing– Response time should be < 1 second

– Each user has at least one program executing in memoryprocess

– If several jobs ready to run at the same time CPU scheduling

– If several jobs are ready to be brought into memory, and if there isnot enough room for all of themJob schedulingnot enough room for all of themJob scheduling

– If processes don’t fit in memory, swapping moves them in and outto run

– Virtual memory allows execution of processes not completely inmemory

– advantage of the virtual-memory scheme is it enables to runprograms that are larger than actual physical memory

Loganathan R, CSE,HKBKCE 22

Page 23: 1 introduction

5. Operating-System Operations OS are Interrupt driven and Events are signaled by Interrupt or trap (or exception)

◦ Division by zero, request for operating system service

Other process problems include infinite loop, processes modifying each other or theoperating system

5.1 Dual-mode operation allows OS to protect itself and other system components

◦ User mode - Executing user application

◦ kernel mode ( Supervisor / System / Privileged) – Boot time / System call

◦ Mode bit indicates current mode (0-Kernal, 1-User) provided by hardware

Loganathan R, CSE,HKBKCE 23

Page 24: 1 introduction

5.2 Timer• Timer to prevent infinite loop / process hogging resources

– Set interrupt after specific period

– A variable timer is generally implemented by a fixed-rateclock and a counter

– Operating system decrements counter

– When counter reach zero an interrupt generated– When counter reach zero an interrupt generated

– Set up before scheduling process to regain control orterminate program that exceeds allotted time

Loganathan R, CSE,HKBKCE 24

Page 25: 1 introduction

6. Process Management• A process is a program in execution. It is a unit of work within the

system i.e. a job or a time-shared program

• Program is a passive entity, process is an active entity.

• Process needs resources to accomplish its task

– CPU, memory, I/O, files, Initialization data

• Process termination requires reclaim of any reusable resources

• Single-threaded process has one program counter specifying location ofnext instruction to executenext instruction to execute

– Process executes instructions sequentially, one at a time, untilcompletion

• Multi-threaded process has one program counter per thread

• Typically system has many processes, some user process, some are OSprocess running concurrently on one or more CPUs

– Concurrency by multiplexing the CPUs among the processes /threads

Loganathan R, CSE,HKBKCE 25

Page 26: 1 introduction

Process Management ActivitiesThe operating system activities inconnection with process management: Creating and deleting both user and system processes

Suspending and resuming processes

Providing mechanisms for process synchronizationProviding mechanisms for process synchronization

Providing mechanisms for process communication

Providing mechanisms for deadlock handling

Loganathan R, CSE,HKBKCE 26

Page 27: 1 introduction

7. Memory Management• All data in memory before and after processing

• All instructions in memory in order to execute

• Memory management determines what is in memory whenOptimizing CPU utilization and computer response to users

• Memory management activities

– Keeping track of which parts of memory are currently– Keeping track of which parts of memory are currentlybeing used and by whom

– Deciding which processes (or parts thereof) and data tomove into and out of memory

– Allocating and deallocating memory space as needed

Loganathan R, CSE,HKBKCE 27

Page 28: 1 introduction

8.Storage Management• OS provides uniform, logical view of information storage

– Abstracts physical properties to logical storage unit - file

– Each medium is controlled by device (i.e., disk drive, tape drive)

• Varying properties include access speed, capacity, data-transferrate, access method (sequential or random)

8.1 File-System management• A File is a collection of information defined by its creator usually

organized into directoriesorganized into directories

• The OS implements the abstract concept of a file by managing massstorage media and the devices that control them

• OS activities in connection with file management

• Creating and deleting files

• Creating and deleting directories to organize files

• Primitives to manipulate files and directories

• Mapping files onto secondary storage

• Backup files onto stable (non-volatile) storage media

Loganathan R, CSE,HKBKCE 28

Page 29: 1 introduction

8.2 Mass-Storage Management• Usually disks used to store data that does not fit in main memory or data

that must be kept for a “long” period of time.

• Proper management is of central importance

• Entire speed of computer operation hinges on disk subsystem and itsalgorithms

• OS activities in connection with disk management

– Free-space management

– Storage allocation

– Disk scheduling

• Some storage need not be fast for backup of disk data

– Tertiary storage includes optical storage, magnetic tape, platters

– Varies between WORM (write-once, read-many-times) and RW (read-write)

– It is not crucial to system performance, but it still must be managed

Loganathan R, CSE,HKBKCE 29

Page 30: 1 introduction

8.3 Caching• Important principle, performed at many levels in a computer

(in hardware, operating system, software)

• Information in use copied from slower to faster storagetemporarily

• Faster storage (cache) checked first to determine ifinformation is there

– If it is, information used directly from the cache– If it is, information used directly from the cache (fast)

– else, data copied to cache and used there

• Cache smaller than storage being cached

– Cache management important design problem

– Cache size and replacement policy

Loganathan R, CSE,HKBKCE 30

Page 31: 1 introduction

Performance of Various Levels of Storage

• Movement between levels of storage hierarchy canbe explicit or implicit

Loganathan R, CSE,HKBKCE 31

Page 32: 1 introduction

Migration of A from Disk to Register• Multitasking environments must be careful to use most

recent value, no matter where it is stored in the storagehierarchy

• Multiprocessor environment must provide cachecoherency in hardware such that all CPUs have the mostrecent value in their cache

• Distributed environment situation even more complex

– Several copies of a datum can exist

Loganathan R, CSE,HKBKCE 32

Page 33: 1 introduction

8.4 I/O Subsystem

One purpose of OS is to hide peculiarities ofhardware devices from the user

• Peculiarities of I/O devices are hidden from theoperating system itself by the I/O subsystem

I/O subsystem components◦ A Memory management component that includes◦ A Memory management component that includes

buffering, caching and spooling

◦ A General device-driver interface

◦ Drivers for specific hardware devices

Only the device driver knows the peculiarities ofthe specific device

Loganathan R, CSE,HKBKCE 33

Page 34: 1 introduction

9. 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 externalattacks– Huge range, including denial-of-service, worms, viruses, identity

theft, theft of service

• Systems generally first distinguish among users, to determinewho can do whatwho can do what– User identities (user IDs, security IDs) include name and associated

number, one per user

– User ID then associated with all files, processes of that user todetermine access control

– Group identifier (group ID) allows set of users to be defined andcontrols managed, then also associated with each process, file

– Privilege escalation allows user to change to effective ID with morerights

Loganathan R, CSE,HKBKCE 34

Page 35: 1 introduction

10 Distributed Systems• A distributed system is a collection of physically separate, possibly

heterogeneous computer systems that are networked to provide the users withaccess to the various resources

• Access to a shared resource increases computation speed, functionality, dataavailability, and reliability

• Distributed systems functionality depend on networking

• Networks vary by the protocols used, the distances between nodes and thetransport media

• TCP/IP is the most common network protocol, although ATM and other• TCP/IP is the most common network protocol, although ATM and otherprotocols (UDP) are in widespread use

• Networks are characterized based on the distances between their nodes suchas LAN,WAN, MAN and Small-Area Network(home)

• The media to carry networks are equally varied that include copper wires, fiberstrands, and wireless transmissions between satellites, microwave dishes, andradios

• A network OS provides features such as file sharing across the network andthat includes a communication scheme that allows different processes ondifferent computers to exchange messages

Loganathan R, CSE,HKBKCE 35

Page 36: 1 introduction

11 Special-Purpose Systems• 11.1 Real-Time Embedded Systems

– Embedded computers found everywhere, from car engines and manufacturing robots toVCRs and microwave ovens and expanding

– Embedded systems almost always run real-time OS, which is used when there is a rigidtime requirements, i.e. processing must be done within the defined constraints

– used as a control device in sensors, scientific experiment, medical imaging, industrialcontrol, display, automobile-engine fuel-injection, home-appliance, weapon systems

• 11.2 Multimedia Systems– Multimedia data consist of audio and video files as well as conventional files– Multimedia data, live webcasts, must be streamed according to certain time restrictions

eg. 30 frames per secondeg. 30 frames per second– A stock trader may have stock quotes delivered wirelessly and in real time to his PDA.

• 11.3 Handheld Systems– personal digital assistants (PDAs), such as Palm and Pocket-PCs, and cellular phones,– Limitation

• Physical memory in a handheld is typically 512 KB to 128 MB• Speed of the processor , Faster processors require more power• I/O lack of physical space limits I/O methods to small keyboards, handwriting recognition, or

small screen-based keyboards and small screens (web clipping is used)

Loganathan R, CSE,HKBKCE 36

Page 37: 1 introduction

12. Computing Environments• 12.1Traditional computing

– Office environment• PCs connected to a network, terminals attached to mainframe or minicomputers

providing batch and timesharing, awkward Remote access and portability• Now portals allowing networked and remote systems access to same resources

– Home networks• Used to be single system, then modems and now firewalled, networked

– Traditional time-sharing systems are uncommon

• 12.2 Client-Server Computing– Dump Terminals are supplemented for PCs– Dump Terminals are supplemented for PCs– Server systems to satisfy requests generated by client systems• Compute-server provides an interface to client to request services (i.e. database)• File-server provides interface for clients to store and retrieve files

Loganathan R, CSE,HKBKCE 37

Page 38: 1 introduction

12. Computing Environments contd..

• 12.3 Peer-to-Peer Computing– Another model of distributed system– P2P does not distinguish clients and servers

• Instead all nodes are considered peers◦ May each act as client, server or both◦ Node must join P2P network and

– Registers its service with central lookup service on network, or– Broadcast request for service and respond to requests for service via

discovery protocoldiscovery protocol◦ Examples include Napster and Gnutella

• 1.12.4 Web-Based Computing– Web has become everywhere and PCs most common devices– More devices becoming networked to allow web access– New category of devices to manage web traffic among similar servers:

load balancers– Use of operating systems like Windows 95, client-side, have evolved into

Linux and Windows XP, which can be clients and servers

Loganathan R, CSE,HKBKCE 38