Slides - CSE, IIT Bombay

Download Report

Transcript Slides - CSE, IIT Bombay

Introduction
Chapter 1
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
What is an operating system ?
•
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
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Abstract views
•
An abstract view focuses on the essential characteristics
of a system
– It contains some selected characteristics, and ignores others
* It helps to control complexity in designing and understanding a
system, by hiding unnecessary detail
– For example, two abstract views of a car:
* The driver’s view contains the rear-view mirror, steering, gear shift,
and speedometer but ignores engine details
* The mechanic’s view contains fluid levels, electrical system, …
Q: Give examples of abstract views
A: View of an abstract data type, object, ..
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Abstract views
•
Abstract views are used in
– Software requirements specification
* Specify what functions a system should perform
 The abstract view of a specific function helps in understanding
the system data and fundamental operations on them
– Software design and implementation
* ‘Hiding’ the details of functions and subsystems while designing or
implementing other functions and subsystems helps to control
complexity
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
A designer’s abstract view of an OS
• 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
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
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
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Goals of an OS
•
Two primary goals of an OS are
– Efficient use of the computer’s resources
* To ensure cost-effectiveness of the computer
– User convenience
* A user should find it easy to use the computer
•
These two goals sometimes conflict
– Prompt service can be provided through exclusive use of a
computer; however, efficient use requires sharing of a
computer’s resources among many users
– An OS designer decides which of the two goals is more
important under what conditions
* That is why we have so many operating systems!
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
User convenience
•
The computing environment influences the notion of user
convenience
– The computing environment is comprised of
* The computer system
* Its interfaces with other systems
* Nature of computations performed by its users
– Computing environments change with the architecture and use
of a computer, e.g. personal computing, online applications,
embedded applications
– Hence the notion of user convenience has several facets that
depend on the computing environment
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
User convenience
•
User convenience has several facets
– Fulfillment of a necessity
* Use of programs and files
– Good service
* Speedy response
– Ease of Use
* User friendliness
– New programming model
* e.g., Concurrent programming
– Web-oriented features
* e.g., Web-enabled servers
– Evolution
* Addition of new features, use of new computers
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Operation of an OS
•
During operation, an OS performs two primary functions
– Program management
* Perform program initiation/termination
* Provide means through which many programs can work toward a
common goal
 Helps in more convenient or faster fulfillment of user
requirements
– Resource management
* Ensure efficient use of resources
 Use of CPU, I/O devices
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Operation of an OS
•
Program management and resource management
require three fundamental tasks
– Scheduling
* Deciding which program should be serviced by the CPU and for
how long
– Resource allocation
* Sharing of resources among user programs
– Security and protection
* Ensuring non-interference between programs
 Security: guarding against interference by external entities
 Protection: guarding against interference by internal entities
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Operation of an OS
•
To facilitate scheduling, resource management, and
security and protection
– OS maintains various kinds of information to facilitate operation
* Names of registered users
* identity of a user who is executing a specific program
* status of a program
* status of a resource
* which users can access a resource
– OS performs several tasks repeatedly to implement scheduling,
resource management, and security and protection
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Common tasks performed by operating systems
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
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
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
A schematic of scheduling
• Programs waiting for CPU attention are entered in a pool
• The scheduler picks one program from the pool for execution on the CPU
• The CPU may be forcibly taken away from a program. This action
is called pre-emption
• A pre-empted program is again entered into the pool
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Resource management
•
Criteria and techniques of resource management
– Criterion: Resource utilization efficiency
* Share the resources wherever possible
* Avoid idling of resources
* Speedy resource allocation and de-allocation is desirable
– Technique 1: Partitioning of resources
* A resource partition is a collection of resources
 A resource partition is allocated to a process
 Simplifies resources allocation and also speeds it up
– Technique 2: Allocation from a pool
* Resources are allocated individually when needed
Q: Pros & cons of the two techniques?
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Virtual resources
•
A virtual resource is an illusion presented to a program
– A virtual resource is an abstraction; its implementation is hidden
from a program
– Use of virtual resources simplifies resource allocation
* Virtual resources may be created if several programs need a
resource. It permits more programs to execute at the same time
– A virtual I/O device is a virtual resource
* The OS implements a virtual device as follows:
 When a program performs an operation on a virtual device, the
operation may be actually performed on some real resource
* Example: virtual printer
 When a program ‘prints’ on a virtual printer, the data is actually
stored in memory; printing takes place sometime later
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Security and Protection
•
An OS must ensure non-interference with users’
programs and data
– Aspects of non-interference
* Resources must not be used by un-authorized persons
* There should be no interference with use of resources by
authorized persons and their programs
– Terminology
* An intruder is a person or program that causes interference
* Security measures avoid interference by non-users and their
programs
* Protection measures avoid interference by users and their programs
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Security and protection techniques
•
Two key techniques of security and protection
– Authentication
* Verification of a user’s identity
* Performed when a person logs in (typically through passwords)
– Authorization: has two aspects
* The owner of a resource selectively permits other users to access
them
* When a user/program tries to access a resource, the OS verifies
whether the user has the permission to perform the access
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Overview of security and protection threats
• Authentication checks whether a person is a registered user
• Threats posed by non-users are security threats
• Threats posed by a user are protection threats
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Preview of the book
•
Part I: Fundamental concepts
– How an OS organizes its own functioning, manages user
programs, and manages computer resources such as the CPU,
memory and files
•
Part II: Advanced topics
– Design of OS features that implement program interactions and
file system services, and facilitate portability and extensibility of
operating systems
•
Part III: Distributed Operating Systems
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Part I: Fundamental concepts
•
How does an OS keep track of activities in its various
units and in user programs?
– An activity causes an event at an appropriate time
* An event is a situation that requires the OS’s attention
– The OS keeps track of events in the computer system and in
user programs. This way it knows the activities in its units and in
programs. For example,
* A log in operation is an event
* An I/O operation is an event
* Completion of a program is an event
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
An operating system in its computing environment
• The computer should be executing user programs most of the time
• When an event occurs, the OS should obtain control to handle the event
Q: How is this achieved?
A: Occurrence of an event raises an interrupt, which switches the CPU to OS
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Execution of programs
•
An execution of a program is called a process
– The OS keeps track of the activity of a process and performs
scheduling to decide which process should be allowed to
operate currently
* Scheduling is the key OS activity for providing
 fast response to users
 good resource utilization
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Managing memory
•
The OS services a large number of processes
simultaneously
– It must make efficient use of memory
– It must perform memory allocation and de-allocation speedily
– These requirements may conflict, hence special techniques are
used to implement effective memory management
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Virtual Memory
•
Users may wish to write very large programs. Some of
these programs may not fit in memory
– The OS uses virtual memory to overcome this problem
* Only some portion(s) of the code and data of a process are present
in memory at any time
* Other portions are loaded in memory when needed
* Portions not presently needed may be removed from memory
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
A schematic of virtual memory operation
• The OS maintains information about portions of a process that are in memory
• A ‘missing from memory’ event occurs if a required portion is not in memory
• The OS now loads it in memory
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
File processing
•
The file system ensures effectiveness of file processing
– Provides convenient methods for a user to create, access and
share files
* Each file organization provides efficient access for a specific record
access patterns
– Provide assurance needed by users
* Security and protection techniques to ensure that files are not
accessed by unauthorized persons
* Reliability techniques to ensure that files are not lost or damaged
due to failures in the system
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Part II: Advanced topics
•
Process synchronization
– Enables processes to work harmoniously towards common goals
•
Message passing
– Facilitates communication among processes
•
Deadlock handling
– Avoids indefinite waits
•
Implementation of file operations
– Techniques to ensure efficiency and reliability
•
Multiprocessor operating systems
– Ensure effective and efficient use of the multiple CPUs
•
Structure of operating systems
– Provides portability and extensibility of operating systems
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Process synchronization
•
Process synchronization is employed for two purposes
– Data sharing
* Processes should share data or resources such that only one
process uses a data item or a resource at any time
 It avoids data inconsistency
– Coordination of activities
* Processes must perform their operations in a desired order
 e.g., if a process wishes to use some data produced by another
process, it must read the data only after the other process has
assigned a value to it
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Two kinds of process synchronization
(a) The Credit and Debit processes share the account balance, hence only
one of them should access it at any time
(b) Generate produces a sample and Analyze analyzes it. Analyze must
wait if Generate has not yet produced a sample
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Deadlocks
•
Some resources cannot be shared across processes;
they must be used by only one process at a time
– If a resource is in use by a process, another process wishing to
use the resource must wait for the process to release it
* Indefinite waits would arise if processes wait for each other
 This situation is called a deadlock
 It degrades response time and efficiency of use
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
A deadlock involving three processes
•
•
•
•
Pk needs a resource that is currently allocated to Pi
Pi needs a resource that is currently allocated to Pj
Pj needs a resource that is currently allocated to Pk
Each of the processes waits indefinitely
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Part III: Distributed Operating Systems
•
A distributed system consists of several computer
systems connected through a network
– Terminology
* A computer, which is called a host or node, exists in a site
– A distributed OS manages computers in a distributed system in a
well-integrated manner to provide two key benefits
* high reliability
 Redundancy of resources in various computers is exploited to
ensure that a process can complete despite failures
* speed-up of a computation by performing some of its parts in
different computer systems
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Issues in Distributed OS
•
Individual computers in a distributed system have their
own clocks and memories
– Clocks in different computers are not synchronized, hence they
may show different times
– It is difficult to obtain a consistent view of data and activities
* E.g., balances in two accounts, recorded while transferring funds
between them, may not be mutually consistent (see next slide)
•
A distributed OS has to use special techniques to ensure
consistency and reliability
– Important during normal operation and recovery from a failure
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Consistency issues in a distributed OS
• An observer in node Z records balances in accounts A and B while
funds are being transferred
• Z may record balance of X before $100 are transferred from it to Y,
and balance of Y after the transfer—$100 are generated!
• Z may record balance of X after $100 are transferred from it to Y,
and balance of Y before the transfer—$100 are lost!
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Issues in Distributed OS
•
Theoretical issues
– How to know the order in which events have occurred?
* Important for FCFS allocation, etc.
– How to know the state of a system
* Important for avoiding inconsistencies and performing ‘load
balancing’ across nodes to obtain good performance
•
Distributed control algorithms
– Parts of the algorithm run in different nodes
* Obviates the need to collect ‘global’ state in one node
* Special techniques are used to ensure consistency of actions
– Used for resource allocation, scheduling, deadlock handling, etc.
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Issues in Distributed OS
•
Recovery
– User computations should not suffer due to node or link failures
* OS restores computations in a failed node to a previous state
* Special techniques are used to ensure consistency across nodes
•
Distributed file systems
– Files can be accessed from any node
* Special techniques are needed to ensure good performance when a
non-local file is accessed
* Special techniques are also needed to ensure reliability when nodes
or network links fail
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008
Issues in Distributed OS
•
Distributed system security
– Security threats arise from intruders, and viruses and worms
– OS must provide measures to
* Prevent intruders from corrupting or fabricating network messages
* Enable processes to verify identities of other processes
* Ensure data security
 Enable users to know who created a document or data
 Enable users to know whether documents or data have been
tampered with
Chapter 1: Introduction
Dhamdhere: Operating Systems—
A Concept-Based Approach, 2 ed
Slide No: ‹#›
Copyright © 2008