Chapter 1 - Introduction. In this chapter, the following content will be discussed: Overview of operating systems, OS and the computer system, memory utilization during operation of an OS, the program status word (PSW), privileged mode of CPU, state of the CPU,...
Trang 1in any form or by any means, without the prior written permission of the publisher, or used beyond the limited distribution to teachers and educators permitted by McGrawHill
Trang 2What 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
Trang 3Abstract 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,
Trang 4Abstract 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
Trang 5A designer’s abstract view of an OS
• User interface: Accepts commands from users: GUI, command line interface
• Nonkernel programs: Implement user commands
• Kernel: Core of the OS─controls the computer, provides functions & services
Trang 6A 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
Trang 7Goals 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!
Trang 8User 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
Trang 9* 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
Trang 10Operation 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
Trang 11Operation of an OS
• Program management and resource management
require three fundamental tasks
* Ensuring non-interference between programs
Trang 12Operation 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
Trang 13Common tasks performed by operating systems
Trang 14Program management
• A computational structure is a configuration of several
programs Three typical computational structures are:
* 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
Trang 16Resource 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
Trang 17Virtual 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
Trang 18Security 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
programs
Trang 19Security 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
Trang 20Overview of security and protection threats
• Authentication checks whether a person is a registered user
• Threats posed by nonusers are security threats
• Threats posed by a user are protection threats
Trang 21Preview 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
Trang 22Part 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
Trang 23An 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
Trang 24Execution 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
Trang 25Managing 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
Trang 26Virtual 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
Trang 27A 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
Trang 28File 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
Trang 29Part II: Advanced topics
– 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
Trang 30* 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
Trang 31Two 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
Trang 32• 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
Trang 33A deadlock involving three processes
• P k needs a resource that is currently allocated to P i
• P i needs a resource that is currently allocated to P j
• P j needs a resource that is currently allocated to P k
• Each of the processes waits indefinitely
Trang 34Part III: Distributed Operating Systems
• A distributed system consists of several computer
systems connected through a network
different computer systems
Trang 35– 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
Trang 36Consistency issues in a distributed OS
Trang 37Issues 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.
Trang 38Issues 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
Trang 39Issues 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