10EC65 Operating Systems - Introduction and Overview of Operating Systems

Page 1

Operating Systems 10EC65 Unit 1 Introduction and Overview of Operating Systems

Reference Book: “Operating Systems - A Concept based Approach” D. M. Dhamdhere, TMH, 3rd Edition, 2010

Shrishail Bhat, AITM Bhatkal


Introduction

• An operating system (OS) is a collection of programs that achieve effective utilization of a computer system by providing – Convenient methods of using a computer • Saves users’ time and boosts their productivity

– Efficient use of the computer

• An OS has several kinds of users – The OS meets diverse requirements of different kinds of users – Each user has a different view of what an OS is, and what it does. Each of these views is called an abstract view Shrishail Bhat, AITM Bhatkal


Abstract Views of an Operating System

• What is an OS? – Abstract views • To a college student: SW that permits access to the Internet • To a programmer: SW that makes it possible to develop programs on a computer system • To a user of an application package: SW that makes it possible to use the package • To a technician in a computerized chemical plant: invisible component of a computer system that controls the plant

– An abstract view focuses only on essential characteristics Shrishail Bhat, AITM Bhatkal


Abstract Views of an Operating System (continued)

• Operating system designer also has an abstract view • User interface: Accepts commands from users: GUI, command line interface • Non-kernel programs: Implement user commands • Kernel: Core of the OS – controls the computer, provides functions & services

• OS is a collection of routines that facilitates execution of user programs and use of resources Shrishail Bhat, AITM Bhatkal


Abstract views

• We use abstract views to present design of OS components. It has two benefits: – Managing complexity • Abstract view contains only selected features of a system

– Presenting a generic view • For example, user interface of Figure 1.2 has many variants in practice – Command line interface – Graphical user interface (GUI)

Shrishail Bhat, AITM Bhatkal


A designer’s abstract view of an OS

• The abstract view consists of three components – The kernel programs • interact with the computer’s hardware and implement the intended operation

– The non-kernel programs • implement creation of programs and use of system resources by them. These programs use kernel programs to control operation of the computer

– The user interface • interprets the commands of a user and activates non-kernel programs to implement them Shrishail Bhat, AITM Bhatkal


Goals of an OS

• Fundamental goals of an operating system – Efficient use of computer resources – User convenience – Noninterference in the activities of its users

• When these goals conflict, designer makes a trade-off for – Efficient use – User convenience

• Notion of effective utilization – Each OS provides a different flavor of effectiveness Shrishail Bhat, AITM Bhatkal


Efficient Use

• OS ensures efficient use of memory, CPU, and I/O devices – Poor efficiency can result if a program does not use a resource allocated to it

• OS itself consumes CPU and memory resources, which constitutes overhead – It reduces resources for user programs

• OS can monitor use of resources to ensure efficiency – It would increase the overhead

• OS uses policies that ensure efficiency Shrishail Bhat, AITM Bhatkal


User Convenience

Shrishail Bhat, AITM Bhatkal


Noninterference

• User can face interference in computational activities – Program execution or operation of OS can be disrupted by actions of other persons • OS prevents interference by allocating resources for exclusive use of programs and OS services, and preventing illegal accesses to resources

– Illegal file access • OS knows which user files can be accessed by whom – Achieved through authorization

Shrishail Bhat, AITM Bhatkal


Operation of an OS

• Principal functions of OS: – Program management – Resource management – Security and protection

Shrishail Bhat, AITM Bhatkal


Operation of an OS (continued)

Shrishail Bhat, AITM Bhatkal


Program Management

• A computational structure is a configuration of several programs. Three typical computational structures are: – A single program • Execution of a program on a given set of data

– A sequence of single programs • A program should be executed only if previous programs in the sequence executed successfully • Programs should pass their results to other programs through files

– Co-executing programs • The OS must execute these programs at the same time • The OS must provide an interface between co-executing programs so that their results are available to one another Shrishail Bhat, AITM Bhatkal


Program Management (continued)

• OS can interleave execution of programs on a fast CPU – Scheduling decides which program should be given the CPU at any time • Policy influences efficient CPU use and user service • Preemption: Taking away the CPU from a program

Shrishail Bhat, AITM Bhatkal


Resource Management

• Resource allocations and deallocations can be done with a resource table – Entry: name, address and status of a resource unit – Constructed by the boot procedure, maintained during operation

Shrishail Bhat, AITM Bhatkal


Resource Management (continued)

• Popular resource allocation strategies: – Resource partitioning • OS decides a priori what resources to allocate to each user program; divides system resources into partitions – A resource partition is a collection of resources

• Resource table contains entries for partitions • Simple to implement, but lacks flexibility

– Pool-based • OS allocates resources from a pool of resources – Consults table and allocates the resource if it is free

• Less overhead of allocating and deallocating resources • Achieves more efficient use of resources Shrishail Bhat, AITM Bhatkal


Resource Management (continued)

Shrishail Bhat, AITM Bhatkal


Resource Management (continued) • A virtual resource is a fictitious resource – – – –

Abstract view of a resource taken by a program Supported by OS through use of a real resource Same real resource may support several virtual ones Started with the use of virtual devices • E.g., a print server

• Provides effect of having more resources • Most OSs provide virtual memory – May execute a program bigger than size of RAM

• Some OSs create virtual machines – Each virtual machine can be allocated to a user Shrishail Bhat, AITM Bhatkal


Security and Protection

• Security counters threats of interference or illegal use posed by persons/programs outside OS control – Authentication: only registered user can use a computer system

• Protection counters threats posed by users of an OS – Memory protection is a HW feature used by OS to thwart disruption of programs and OS services – Authorization thwarts interference with files

Shrishail Bhat, AITM Bhatkal


Security and Protection (continued)

Shrishail Bhat, AITM Bhatkal


Security and Protection (continued)

• Intruders are outsiders who can cause interference – May use or create malicious programs • Trojan horse – a program that has a known legitimate function and a well-disguised malicious function • Virus – a piece of code with a malicious function that attaches itself to other programs in the system and spreads to other systems when such programs are copied • Worms – programs that replicate by themselves through holes in security setups of operating systems

• Methods of addressing security threats – Authentication techniques – Plugging security holes – Internet firewalls Shrishail Bhat, AITM Bhatkal


OS and the Computer System

• The memory is divided into a system area and a user area. • Some OS programs exist permanently in the system area of the memory to monitor and control activities in the computer system. They form the kernel. • Other programs exist on a disk and are loaded in the transient area when needed. • Remainder of the memory is occupied by user programs.

Shrishail Bhat, AITM Bhatkal


Memory Utilization

Figure shows use of memory during operation of an OS

Shrishail Bhat, AITM Bhatkal


Fundamental Principles of OS Operation

• The kernel of the OS is the collection of routines that form the core of the operating system – Implements control functions – Set of services to user programs – Exists in memory during operation of the OS

• The kernel is a collection of programs, and not a hardware unit. • The kernel performs control functions by executing instructions on the CPU. Shrishail Bhat, AITM Bhatkal


Fundamental Principles of OS Operation (continued)

• Thus the CPU is used by both, user programs and the OS. • Switching – The action that forces the CPU to stop executing one program and start executing another program. • Switching of the CPU between user programs and the kernel is the most crucial aspect of the OS.

Shrishail Bhat, AITM Bhatkal


The Computer System

The figure shows a model of a computer system that shows only those functional units that are relevant from the viewpoint of an OS.

Shrishail Bhat, AITM Bhatkal


The Computer System (continued)

• • • • •

The CPU Memory Management Unit (MMU) Memory Hierarchy Input/Output Interrupts

Shrishail Bhat, AITM Bhatkal


The CPU

• CPU has two modes of operation: – Kernel mode • CPU can execute all instructions • Kernel operates with CPU in this mode so that it can control computer operations

– User mode • CPU cannot execute instructions that could interfere with other programs or with the OS if used indiscriminately • CPU is put in this mode to execute user programs

Shrishail Bhat, AITM Bhatkal


The CPU (continued)

• Two features of the CPU are visible to user programs or the OS: – General-purpose registers (GPRs) • Also called program-accessible registers • Hold data, addresses, index values, or the stack pointer during execution of a program

– Control registers • Contain information that controls or influences operation of the CPU • Set of control registers is called the program status word (PSW)

Shrishail Bhat, AITM Bhatkal


Shrishail Bhat, AITM Bhatkal


The CPU (continued)

• CPU can operate in two modes: – Kernel mode • Can execute privileged instructions • OS puts CPU in kernel mode when it is executing instructions in the kernel

– User mode • Cannot execute privileged instructions • OS puts CPU in user mode while executing user programs

• Mode (M) field of PSW contains 0 if CPU is in privileged mode and 1 if it is in user mode Shrishail Bhat, AITM Bhatkal


State of the CPU

• GPRs and PSW contain the information needed to know what the CPU is doing – State of the CPU

• Kernel saves state of CPU when it takes away the CPU from program – When program is to be resumed, it reloads the saved CPU state into GPRs and PSW

Shrishail Bhat, AITM Bhatkal


Example: State of the CPU (continued)

Shrishail Bhat, AITM Bhatkal


Memory Management Unit (MMU)

• Virtual memory is an illusion of memory that may be larger than the real memory of a computer – Implemented using noncontiguous memory allocation and the MMU • CPU passes the address of data or instruction used in an instruction to MMU – It is called the logical addresses

• MMU translates logical address to physical address

Shrishail Bhat, AITM Bhatkal


Memory hierarchy

• The memory hierarchy provides a large and fast memory, at a low cost – It is an arrangement of several memories with different access speeds and sizes • The CPU accesses only the fastest memory; i.e., the cache • If a required byte is not present in the memory being accessed, it is loaded there from a slower memory

Shrishail Bhat, AITM Bhatkal


Operating Systems, by Dhananjay Dhamdhere

2.36

Shrishail Bhat, AITM Bhatkal


Memory Hierarchy (continued)

• When CPU performs a cache lookup, a cache hit or miss may occur – Hit ratio (h) of the cache is the fraction of bytes accessed by the CPU that score a hit in the cache tema = h × tcache + (1 – h) × (ttra + tcache) = tcache + (1 – h) × ttra

where tema = effective memory access time, tcache = access time of cache, and ttra = time taken to transfer a cache block from memory to cache.

Shrishail Bhat, AITM Bhatkal


Memory Hierarchy (continued)

• Operation of memory is analogous to operation of a cache – Blocks of bytes (pages) are transferred from disk to memory or from memory to disk – But, • Memory management and transfer of blocks between memory and disk are performed by SW • In the cache, the transfer is performed by HW

• Memory hierarchy comprising MMU, memory, and the disk is called the virtual memory Shrishail Bhat, AITM Bhatkal


Memory Hierarchy (continued)

• Many programs coexist in the memory of the computer system • So it is necessary to prevent instructions of one program from destroying contents of memory being used by another program • This function is called memory protection

Shrishail Bhat, AITM Bhatkal


Memory Hierarchy (continued)

• Memory protection is implemented by checking whether a memory address used by a program lies outside the memory area allocated to it – Control registers used: • base and size (also called limit) – Address of first byte = <base> – Address of last byte = <base> +<size> – 1

Shrishail Bhat, AITM Bhatkal


Shrishail Bhat, AITM Bhatkal


The Input/Output Subsystem

Shrishail Bhat, AITM Bhatkal


Interrupts

• The function of an interrupt is to draw the kernel’s attention to a condition or an event that has occurred in the system. • An event is a situation that requires OS’s attention – Designer associates an interrupt with each event • Purpose is to report occurrence of the event to OS and enable it to perform event handling actions

• Interrupt action saves CPU state and loads new contents into the PSW and GPRs – CPU starts executing instructions of an interrupt servicing routine (ISR) in the kernel

Shrishail Bhat, AITM Bhatkal


Interrupts (continued)

Shrishail Bhat, AITM Bhatkal


Interrupt Masking

• The Interrupt Mask (IM) field of the PSW indicates which interrupts are permitted to occur at any moment of time. • The field may contain an integer m, in which case only interrupts with priority≥m are permitted to occur.

Shrishail Bhat, AITM Bhatkal


Shrishail Bhat, AITM Bhatkal


OS Interaction with the Computer and User Programs

• OS interacts with the computer to – know information about events, so that it can service them – restore CPU state to resume a program after servicing an interrupt

• Programs need to use services of the OS for purposes such as initiating an I/O operation – The method to cause an interrupt and pass requirement to the OS is known as a System call

Shrishail Bhat, AITM Bhatkal


Controlling Execution of Programs

1. When user program starts, PSW should contain: a. Program counter (PC) field b. Mode (M) field, set to user mode (1) c. Memory protection information (MPI) field contains start address in memory and size of program d. Interrupt mask (IM) field, set to enable interrupts

2. When program is interrupted, CPU state (PSW and GPRs) are saved • Program table or process control block (PCB)

3. When program is resumed, its CPU state is restored Shrishail Bhat, AITM Bhatkal


Interrupt Servicing • Context save saves CPU state of the program • The scheduler selects a a program for execution

Shrishail Bhat, AITM Bhatkal


Interrupt Servicing (continued)

Shrishail Bhat, AITM Bhatkal


Shrishail Bhat, AITM Bhatkal


Interrupt Servicing (continued)

• Two approaches for nested interrupt servicing: – Disable nested interrupts through masking – Handle nested interrupts─preemptible kernel

Shrishail Bhat, AITM Bhatkal


System Calls

Shrishail Bhat, AITM Bhatkal


System Calls (continued)

Shrishail Bhat, AITM Bhatkal


Efficiency, System Performance, and User Service

• Two of the fundamental goals of an OS: – Efficiency of use • Of a resource

– User convenience • Measurable aspect: User service – Turnaround time – Response time

• To a system administrator, performance of a system in its environment is more important – Typically measured as throughput Operating Systems, by

Shrishail Bhat, AITM Bhatkal


Efficiency, System Performance, and User Service (continued)

Shrishail Bhat, AITM Bhatkal


Computations in an OS

Shrishail Bhat, AITM Bhatkal


Classes of Operating Systems

Shrishail Bhat, AITM Bhatkal


Efficiency and user convenience in different OS classes

Shrishail Bhat, AITM Bhatkal


Classes of Operating Systems (continued)

Shrishail Bhat, AITM Bhatkal


Batch Processing Systems

• Punched cards were the primary input medium, so a job and its data consisted of a deck of cards • A computer operator would load the cards into the card reader to set up the execution of a job • This action wasted precious CPU time; batch processing was introduced to prevent this wastage

Shrishail Bhat, AITM Bhatkal


Batch Processing Systems (continued)

• Batch: sequence of user jobs formed for processing by the OS • Batching kernel (Batch Monitor) initiates processing of jobs without requiring computer operator’s intervention • Batch Monitor performs 3 functions – Scheduling – Memory Management – Sharing and Protection

• A computer operator formed a batch by arranging a few user jobs in a sequence and inserting special marker cards to indicate the start and end of the batch • The operator had to intervene only at the start and end of a batch Shrishail Bhat, AITM Bhatkal


Batch Processing Systems (continued)

Shrishail Bhat, AITM Bhatkal


Batch Processing Systems (continued) • Card readers and printers were a performance bottleneck in the 1960s – Virtual card readers and printers implemented through magnetic tapes were used to solve this problem

• A batch of jobs was first recorded on a magnetic tape, using a less powerful and cheap computer • The batch processing system processed these jobs from the tape, which was faster than processing them from cards, and wrote their results on another magnetic tape • These were later printed and released to users • Two spooling operations called inspooling and outspooling were performed Shrishail Bhat, AITM Bhatkal


Batch Processing Systems (continued)

• The turnaround time of a job processed in a batch processing system includes – Time until a batch is formed – Time spent in executing all jobs of the batch – Time spent in printing and sorting the results belonging to different jobs

Shrishail Bhat, AITM Bhatkal


Batch Processing Systems (continued)

• Control statements are used to protect against interference between jobs • Command processor reads a control statement, analyses it and carries out the required action

Shrishail Bhat, AITM Bhatkal


Multiprogramming Systems

• Concurrency of operation between the CPU and the I/O subsystem can be exploited to get more work done in the system • The OS can put many user programs in the memory and let the CPU execute instructions of one program while the I/O subsystem is busy with an I/O operation for another program. • This technique is called multiprogramming

Shrishail Bhat, AITM Bhatkal


Multiprogramming Systems (continued)

• Multiprogramming Systems provide efficient resource utilization in a noninteractive environment • They use DMA mode of I/O – Can perform I/O operations of some program(s) while using the CPU to execute some other program • Makes efficient use of both the CPU and I/O devices

• Turnaround time of a program is the appropriate measure of user service in these systems Shrishail Bhat, AITM Bhatkal


Multiprogramming Systems (continued)

Shrishail Bhat, AITM Bhatkal


Multiprogramming Systems (continued)

Shrishail Bhat, AITM Bhatkal


Multiprogramming Systems (continued)

• Important functions of the multiprogramming kernel are: – Scheduling – Memory management – I/O management

Shrishail Bhat, AITM Bhatkal


Multiprogramming Systems (continued)

• An appropriate measure of performance of a multiprogramming OS is throughput – Ratio of the number of programs processed and the total time taken to process them

• OS keeps enough programs in memory at all times, so that CPU and I/O devices are not idle – Degree of multiprogramming: number of programs – Uses an appropriate program mix of CPU-bound programs and I/O-bound programs – Assigns appropriate priorities to CPU-bound and I/O-bound programs Shrishail Bhat, AITM Bhatkal


Multiprogramming Systems (continued)

Shrishail Bhat, AITM Bhatkal


Priority of Programs

• When many program are ready to use the CPU, the multiprogramming kernel gives the CPU to the program with the highest priority. • This rule leads to preemption of a low priority program when a high priority program becomes ready to use the CPU.

Shrishail Bhat, AITM Bhatkal


Priority of Programs (continued) • In multiprogramming environments, an I/O-bound program should have a higher priority than a CPU-bound program.

Shrishail Bhat, AITM Bhatkal


Performance of Multiprogramming systems • How to improve performance?

Shrishail Bhat, AITM Bhatkal


Performance of Multiprogramming systems (continued)

• When an appropriate program mix is maintained, an increase in the degree of multiprogramming would result in an increase in throughput. Shrishail Bhat, AITM Bhatkal


Time-Sharing Systems

• In an interactive computing environment, a user can provide inputs to a program from the keyboard and examine its output on the monitor screen • A different OS paradigm is used in such environments to provide quick service to user requests • It creates an illusion that each user has a computer system at his sole disposal • This paradigm is called time-sharing Shrishail Bhat, AITM Bhatkal


Time-Sharing Systems (continued)

• User service is characterized in terms of the response time (rt) (Response time – time taken to service a subrequest) • So the time-sharing kernel must provide good response times to all users • To realize this goal, all users must get an equal opportunity to present their computational requests and have them serviced

Shrishail Bhat, AITM Bhatkal


Time-Sharing Systems (continued)

• Two provisions are made to ensure this: – Programs are not assigned priorities, instead executed by turn – A program is prevented from consuming unreasonable amounts of CPU time when scheduled to execute

• These provisions are implemented using techniques of roundrobin scheduling and time slicing, respectively

Shrishail Bhat, AITM Bhatkal


Time-Sharing Systems (continued)

• Round-robin scheduling with time-slicing – Kernel maintains a scheduling queue – If time slice (δ) elapses before process completes servicing of a subrequest, kernel preempts it, moves it to end of queue, and schedules another process • Implemented through a timer interrupt

Shrishail Bhat, AITM Bhatkal


Time-Sharing Systems (continued)

Shrishail Bhat, AITM Bhatkal


Time-Sharing Systems (continued) • Response time (rt): measure of user service – If processing of a subrequest requires δ CPU seconds

where η: CPU efficiency, σ: scheduling overhead, n: number of users using system, δ: time required to complete a subrequest

• Actual response time would be different because – Some users may be inactive – Some programs may require > δ CPU seconds Shrishail Bhat, AITM Bhatkal


Time-Sharing Systems (continued)

Shrishail Bhat, AITM Bhatkal


Memory Management: Swapping of Programs

• An inactive program is one which is neither executing on the CPU, nor performing an I/O operation. • The program existing in the memory are classified into three categories: – Active programs – Programs being swapped out of the memory – Programs being swapped into the memory Shrishail Bhat, AITM Bhatkal


Swapping of Programs (continued)

Shrishail Bhat, AITM Bhatkal


Swapping of Programs (continued)

Shrishail Bhat, AITM Bhatkal


Real-Time Operating Systems

• In real-time applications, users need computer to perform some actions in a timely manner – To control activities in an external system, or to participate in them – Timeliness depends on time constraints

• If application takes too long to respond to an activity, a failure can occur in the external system – Response requirement: largest value of response time for which the system can function properly – Deadline: time by which action should be performed 3.88

Shrishail Bhat, AITM Bhatkal


Hard and Soft Real-Time Systems

• A hard real-time system meets response requirements under all conditions – It is typically dedicated to processing real-time applications – e.g., air traffic control systems, ABS, satellite control systems

• A soft real-time system makes best effort to meet response requirement of a real-time application – Cannot guarantee that it will be able to meet it • Meets requirements in a probabilistic manner

– e.g., multimedia applications, applications like reservations and banking Shrishail Bhat, AITM Bhatkal


Features of a Real-Time Operating System

Shrishail Bhat, AITM Bhatkal


Real-Time Operating Systems (continued) • A real-time OS employs two techniques to ensure continuity of operation when faults occur—fault tolerance and graceful degradation • A fault-tolerant computer system uses redundancy of resources to ensure that the system will keep functioning even if a fault occurs – e.g., it may have two disks even though the application actually needs only one disk.

• Graceful degradation is the ability of a system to fall back to a reduced level of service when a fault occurs and to revert to normal operations when the fault is rectified – The programmer can assign high priorities to crucial functions so that they would be performed in a timely manner even when the system operates in a degraded mode Shrishail Bhat, AITM Bhatkal


Distributed Operating Systems

• A distributed computer system consists of several individual computer systems connected through a network – Each computer system could be a PC, a multiprocessor system, or a cluster – Many resources of a kind exist in system – Handling network or individual computers’ failure requires special techniques – Users must use special techniques to access resources over the network Shrishail Bhat, AITM Bhatkal


Distributed Operating Systems (continued)

Shrishail Bhat, AITM Bhatkal


Special Techniques of Distributed Operating Systems

Shrishail Bhat, AITM Bhatkal


Modern Operating Systems

Shrishail Bhat, AITM Bhatkal


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.