0% found this document useful (0 votes)
41 views67 pages

Chapter 1 Introduction New

Uploaded by

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

Chapter 1 Introduction New

Uploaded by

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

Operating System

Chapter 1

Presented By:- Dr. Sanjeev Sharma


What is Operating system
• It is a control program that provides an interface between the
computer hardware and the user.
• Part of this interface includes tools and services for the user.
• From Silberschatz (page 3): “An operating system is a
program that acts as an intermediary between a user of
computer and computer hardware. The purpose of the OS is
provide an environment in which the user can execute
programs.
• The primary goal of an OS is thus to make the computer
convenient to use.
• A secondary goal is to use the computer hardware in an
efficient manner.”
Abstract view of the computer System
• Computer Hardware – CPU, memory, I/O devices provide
basic computing resources.
• System and Application Programs – Compilers, database
systems, games, business programs, etc. define the ways the
computing resources are used to solve the user’s problems.
• Operating System – Controls and coordinates the computing
resources among the system and application programs for the
users.
• End User – Views the computer system as a set of
applications. The End User is generally not concerned with
various details of the hardware.
• Programmer – Uses languages, utilities (frequently used
functions) and OS services (linkers, assemblers, etc.) to
develop applications instead. This method is used to reduce
complexity by abstracting the detail of machine dependant
calls into APIs and various utilities and OS services.

• OS – Masks the hardware details from the programmer and


provides an interface to the system. Manages the computers
resources. The OS designer has to be familiar with user
requirements and hardware details.
Functions of Operating System

• Memory Management
• Processor Management
• Device Management
• File Management
• Security
• Control over system performance
• Job accounting
• Error detecting aids
• Coordination between other software and users
• Memory management refers to management of Primary
Memory or Main Memory.
• Main memory is a large array of words or bytes where each
word or byte has its own address.
• Main memory provides a fast storage that can be accessed
directly by the CPU.
• For a program to be executed, it must in the main memory.
• An Operating System does the following activities for memory
management:
– Keeps tracks of primary memory, i.e., what part of it are in use
by whom, what parts are not in use?
– In multiprogramming, the OS decides which process will get
memory when and how much.
– Allocates the memory when a process requests it to do so.
– De-allocates the memory when a process no longer needs it or
has been terminated.
Processor Management

• In multiprogramming environment, the OS decides which


process gets the processor when and for how much time. This
function is called process scheduling. An Operating System
does the following activities for processor management:
– Keeps tracks of processor and status of process. The program
responsible for this task is known as traffic controller.
– Allocates the processor (CPU) to a process.
– De-allocates processor when a process is no longer required
Device Management
• An Operating System manages device communication via their
respective drivers. It does the following activities for device
management:
– Keeps tracks of all devices. The program responsible for this task
is known as the I/O controller.
– Decides which process gets the device when and for how much
time.
– Allocates the device in the most efficient way.
– De-allocates devices.
File Management
• A file system is normally organized into directories for easy
navigation and usage. These directories may contain files and
other directions.
• An Operating System does the following activities for file
management:
– Keeps track of information, location, uses, status etc. The
collective facilities are often known as file system.
– Decides who gets the resources.
– Allocates the resources.
– De-allocates the resources.
Other Important Activities
• Security - By means of password and similar other techniques,
it prevents unauthorized access to programs and data.
• Control over system performance - Recording delays
between request for a service and response from the system.
• Job accounting -- Keeping track of time and resources used
by various jobs and users.
• Error detecting aids - Production of dumps, traces, error
messages, and other debugging and error detecting aids.
• Coordination between other software and users -
Coordination and assignment of compilers, interpreters,
assemblers and other software to the various users of the
computer systems.
Operating system Evolution
• Let’s see how operating systems evolve over time.
• This will help us to identify some common features of
operating systems and how and why these systems have been
developed as they are.
• Serial Processing
• Simple Batch Systems (1960)
• Multiprogrammed Batch Systems (1970)
• Time-Sharing and Real-Time Systems (1970)
• Personal/Desktop Systems (1980)
• Multiprocessor Systems (1980)
• Networked/Distributed Systems (1980)
Early System
• Structure
– Single user system.
– Large machines run from console.
– Programmer/User as operator.
– Paper Tape or Punched cards.
– No tapes/disks in computer.

• Significant amount of setup time.


• Low CPU utilization.
• But very secure
Batch Operating System
• The users of a batch operating system do not interact with the
computer directly. Each user prepares his job on an off-line
device like punch cards and submits it to the computer
operator. To speed up processing, jobs with similar needs are
batched together and run as a group. The programmers leave
their programs with the operator and the operator then sorts the
programs with similar requirements into batches.
• The problems with Batch Systems are as follows:
– Lack of interaction between the user and the job.
– CPU is often idle, because the speed of the mechanical I/O
devices is slower than the CPU.
– Difficult to provide the desired priority.
• Here First the pooled jobs are read and executed by the batch
monitor, and then these jobs are grouped; placing the identical
jobs (jobs with the similar needs) in the same batch, So, in the
batch processing system, the batched jobs were executed
automatically one after another saving its time by performing
the activities (like loading of compiler) only for once. It
resulted in improved system utilization due to reduced turn
around time.
• The operating systems (called resident monitor) manages the
execution of each program in the batch.
– Monitor utilities are loaded when needed.
– Resident monitor is always in main memory and available for
execution.
– The resident monitor usually has the following part.
• Control card interpreter – responsible for reading and
carrying out instructions on the cards.
• Loader – loads systems programs and applications
programs into memory.
• Device drivers – know special characteristics and
properties for each of the system’s I/O devices.
• One big problem associate with these OS is CPU was often
idle.
• To over come this spooling can be used.
• Uniprogramming Until Now
– I/O operations are exceedingly slow (compared to instruction
execution).
– A program containing even a very small number of I/O
operations will spend most of its time waiting for them.
– Hence: poor CPU usage when only one program is present in
memory.
Memory model for uniprogramming
Multiprogrammed Batch Systems

• Several jobs are kept in main memory at the same time, and
the CPU is multiplexed among them.
• If memory can hold several programs, then CPU can switch to
another one whenever a program is waiting for an I/O to
complete – This is multiprogramming.
Time-sharing Operating Systems

• Time-sharing is a technique which enables many people,


located at various terminals, to use a particular computer
system at the same time.
• Time-sharing or multitasking is a logical extension of
multiprogramming.
• Processor's time which is shared among multiple users
simultaneously is termed as time-sharing.
• The main difference between Multiprogrammed Batch
Systems and Time-Sharing Systems is that in case of
Multiprogrammed batch systems, the objective is to maximize
processor use, whereas in Time-Sharing Systems, the objective
is to minimize response time.
• Multiple jobs are executed by the CPU by switching between
them, but the switches occur so frequently. Thus, the user can
receive an immediate response. For example, in a transaction
processing, the processor executes each user program in a
short burst or quantum of computation. That is, if n users are
present, then each user can get a time quantum. When the user
submits the command, the response time is in few seconds at
most.
• Advantages of Timesharing operating systems are as follows:
– Provides the advantage of quick response
– Avoids duplication of software
– Reduces CPU idle time

• Disadvantages of Time-sharing operating systems are as


follows:
– Problem of reliability
– Question of security and integrity of user programs and data
– Problem of data communication
Distributed Operating System

• Distribute the computation among several physically separated


processors.
• Loosely coupled system – each processor has its own local
memory; processors communicate with one another through
various communications lines, such as high-speed buses or
telephone lines.
• These processors are referred as sites, nodes, computers, and
so on.
• The advantages of distributed systems are as follows:
– With resource sharing facility, a user at one site may be able to
use the resources available at another.
– Speedup the exchange of data with one another via electronic
mail.
– If one site fails in a distributed system, the remaining sites can
potentially continue operating.
– Better service to the customers.
– Reduction of the load on the host computer.
– Reduction of delays in data processing.
Network Operating System

• A Network Operating System runs on a server and provides


the server the capability to manage data, users, groups,
security, applications, and other networking functions. The
primary purpose of the network operating system is to allow
shared file and printer access among multiple computers in a
network, typically a local area network (LAN), a private
network or to other networks.

• Examples of network operating systems include Microsoft
Windows Server 2003, Microsoft Windows Server 2008,
UNIX, Linux, Mac OS X, Novell NetWare
• The advantages of network operating systems are as follows:
– Centralized servers are highly stable.
– Security is server managed.
– Upgrades to new technologies and hardware can be easily
integrated into the system.
– Remote access to servers is possible from different locations and
types of systems.

• The disadvantages of network operating systems are as follows:


– High cost of buying and running a server.
– Dependency on a central location for most operations.
– Regular maintenance and updates are required.
Real-Time Operating System

• A real-time system is defined as a data processing system in which the


time interval required to process and respond to inputs is so small that it
controls the environment. The time taken by the system to respond to an
input and display of required updated information is termed as the
response time. So in this method, the response time is very less as
compared to online processing.

• Real-time systems are used when there are rigid time requirements on the
operation of a processor or the flow of data and real-time systems can be
used as a control device in a dedicated application. A real-time operating
system must have well-defined, fixed time constraints, otherwise the
system will fail. For example, Scientific experiments, medical imaging
systems, industrial control systems, weapon systems, robots, air traffic
control systems, etc.
• There are two types of real-time operating systems.
• Hard real-time systems
Hard real-time systems guarantee that critical tasks complete on time. In
hard real-time systems, secondary storage is limited or missing and the
data is stored in ROM. In these systems, virtual memory is almost never
found.

• Soft real-time systems


• Soft real-time systems are less restrictive. A critical real-time task gets
priority over other tasks and retains the priority until it completes. Soft
real-time systems have limited utility than hard real-time systems. For
example, multimedia, virtual reality, Advanced Scientific Projects like
undersea exploration and planetary rovers, etc.
Operating system services
• An Operating System supplies different kinds of services to both the
users and to the programs as well.
• Here is a list of common services offered by an almost all operating
systems:
– User Interface
– Program Execution
– File system manipulation
– Input / output Operations
– Communication
– Resource Allocation
– Error Detection
– Accounting
– Security and protection
• User Interface of Operating System
• Usually Operating system comes in three forms or types.
Depending on the interface their types have been further sub
divided. These are:
– Command line interface:- which uses text commands and a
method for entering them.
– Batch based interface:- In which the command and directive to
control those command are entered into files.
– Graphical User Interface:- pointing device to direct I/O.
• Program Execution in Operating System
The operating system must have the capability to load a program
into memory and execute that program. Furthermore, the program
must be able to end its execution, either normally or abnormally /
forcefully.

• File System Manipulation in Operating System


Programs need has to be read and then write them as files and
directories. File handling portion of operating system also allows
users to create and delete files by specific name along with
extension, search for a given file and / or list file information. Some
programs comprise of permissions management for allowing or
denying access to files or directories based on file ownership.
• I/O operations in Operating System
• A program which is currently executing may require I/O, which may
involve file or other I/O device. For efficiency and protection, users cannot
directly govern the I/O devices. So, the OS provide a means to do I/O Input
/ Output operation which means read or write operation with any file.

• Communication System of Operating System


• Process needs to swap over information with other process. Processes
executing on same computer system or on different computer systems can
communicate using operating system support. Communication between two
processes can be done using shared memory or via message passing.
• Resource Allocation of Operating System
• When multiple jobs running concurrently, resources must need to be
allocated to each of them. Resources can be CPU cycles, main memory
storage, file storage and I/O devices. CPU scheduling routines are used
here to establish how best the CPU can be used.

• Error Detection
• Errors may occur within CPU, memory hardware, I/O devices and in the
user program. For each type of error, the OS takes adequate action for
ensuring correct and consistent computing.
• Accounting
• This service of operating system keeps track of which users are using how
much and what kinds of computer resources has been used for accounting
or simply to accumulate usage statistics.

• Protection and Security


• Protection includes in ensuring all access to system resources in a
controlled manner. For making a system secure, the user needs to
authenticate him or her to the system before using (usually via login ID and
password).
Interrupt Processing

• An interrupt is a signal that causes the computer to alter its


normal flow of instruction execution.
• eg. divide by zero, time out, I/O operation

• The interrupt automatically transfers control to an interrupt


processing routine which takes some action in response to the
condition that caused the interrupt, and then control is returned
to the program at which its execution was interrupted.
Some interrupt types:

• - I/O interrupt: Generated by an I/O channel or device.



• - Program interrupt: Generated by some condition that occurs
during program execution (eg. divide by zero, illegal machine
instruction, etc.)

• - Timer interrupt: Generated by an internal timer within the
CPU

• - Supervisor call interrupt (SVC): A SVC instruction generates
an interrupt that transfers control to an OS service routine. The
CPU switches from user mode to supervisor mode.
• When an interrupt occurs, the status of the CPU is saved (registers,
program counter etc.) and the interrupt service routine is executed.
After the interrupt is processed, they are restored by the interrupt
routine and control is transferred to the program. Saving and
restoring the processor status is called context switching.

• Interrupt priority: During the processing of an interrupt, all


interrupts of equal or lower priority are inhibited, higher priority
interrupts are allowed. At the end of an interrupt, if there are more
than one interrupt pending, one with the highest priority is
executed.

• Interrupt masking, is used to prevent certain interrupts from


occurring while the first one is being processed.
Operating System Operation
• Modern operating systems are interrupt driven.

• Events are almost always signaled by the occurrence of


interrupt or a trap.

• A trap (or an exception ) is a s/w generated interrupt. (divide


by zero)
• For each type of interrupt, separate segment of code in the OS
determine what action should be taken.
• An interrupt service routine is provided for that.
• A basic example of an ISR is a routine that handles keyboard
events, such as pressing or releasing a key. Each time a key is
pressed, the the ISR processes the input.

• For example, if you press and hold the right arrow key in a text file,
the ISR will signal to the CPU that the right arrow key is depressed.
The CPU sends this information to the active word processor or text
editing program, which will move the cursor to the right.

• When you let go of the key, the ISR handles the "key up" event.
This interrupts the previous "key down" state, which signals to the
program to stop moving the cursor.
Dual mode operation

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


components
– User mode (1) and kernel mode (0)
– 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
• Timer to prevent infinite loop / process hogging resources
– Set interrupt after specific period
– Operating system decrements counter
– When counter zero generate an interrupt
– Set up before scheduling process to regain control or terminate
program that exceeds allotted time
Distributing Computing
• A distributed system is a network of autonomous computers
that communicate with each other in order to achieve a goal.

• The computers in a distributed system are independent and do


not physically share memory or processors. They communicate
with each other using messages, pieces of information
transferred from one computer to another over a network.

• Messages can communicate many things: computers can tell


other computers to execute a procedures with particular
arguments, they can send and receive packets of data, or send
signals that tell other computers to behave a certain way.
• Computers in a distributed system can have different roles.
• A computer's role depends on the goal of the system and the
computer's own hardware and software properties.
• There are two predominant ways of organizing computers in a
distributed system.
• The first is the client-server architecture, and the second is the
peer-to-peer architecture.
System Call
• The system call provides an interface to the operating system
services.
• As we know that for performing any Operation as user must
have to specify the Operation which he wants to Operate on
the Computer.
• We can say that For Performing any Operation a user must
have to Request for a Service from the System.
• For Making any Request a user will prepare a Special call
which is also known as the System Call.
• The System Call is the Request for Running any Program and
for Performing any Operation on the System.
• When a user First Time Starts the System then the System is
in the user Mode and When he request For a Service then
the User Mode will be Converted into the Kernel Mode
Which just Listen the Request of the user and Process the
Request and Display the Results those are Produced after the
Processing.
• For example, for I/O a process involves a system call telling
the operating system to read or write particular area and this
request is satisfied by the operating system.
• Types of System calls
– Process control
– File management
– Device management
– Information maintenance
– Communications
• 1) Process Control: elcgwwa
• A running program needs to be able to stop execution either
normally or abnormally.
• Following are functions of process control:
– end, abort
– load, execute
– create process, terminate process
– get process attributes, set process attributes
– wait for time
– wait event, signal event
– allocate and free memory
• 2) File management :
• We first need to be able to create and delete files. Either system call
requires the name of the file and perhaps some of the file's
attributes.
• Once the file is created, we need to open it and to use it. We may
also read, write, or reposition. Finally, we need to close the file,
indicating that we are no longer using it.
• We may need these same sets of operations for directories if we
have a directory structure for organizing files in the file system.
• In addition, for either files or directories, we need to be able to
determine the values of various attributes and perhaps to reset them
if necessary. File attributes include the file name, a file type,
protection codes, accounting information, and so on
• Functions:
• create file, delete file
• open, close file
• read, write, reposition
• get and set file attributes
• 3) Device Management:
• A process may need several resources to execute - main memory, disk
drives, access to files, and so on. If the resources are available, they can
be granted, and control can be returned to the user process. Otherwise, the
process will have to wait until sufficient resources are available.
• The various resources controlled by the OS can be thought of as devices.
Some of these devices are physical devices (for example, tapes), while
others can be thought of as abstract or virtual devices (for example.
• Once the device has been requested (and allocated to us), we can read,
write, and (possibly) reposition the device, just as we can with files.
• In fact, the similarity between I/O devices and files is so great that many
OSs, including UNIX, merge the two into a combined file-device
structure.
• A set of system calls is used on files and devices. Sometimes, 1/0 devices
are identified by special file names, directory placement, or file attributes.
• Functions:
• request device, release device
• read, write, reposition
• get device attributes, set device attributes
• logically attach or detach devices
• Information Maintenance
• Many system calls exist simply for the purpose of transferring
information between the user program and the OS. For example,
most systems have a system call to return the current time and date.
• Other system calls may return information about the system, such as
the number of current users, the version number of the OS, the
amount of free memory or disk space, and so on.
• In addition, the OS keeps information about all its processes, and
system calls are used to access this information. Generally, calls are
also used to reset the process information.
• Functions:
• get time or date, set time or date
• get system data, set system data
• get and set process, file, or device attributes
• Communication
• There are two common models of interprocess communication: the
message-passing model and the shared-memory model. In the
message-passing model, the communicating processes exchange
messages with one another to transfer information.
• In the shared-memory model, processes use shared memory creates and
shared memory attaches system calls to create and gain access to regions
of memory owned by other processes.
• Recall that, normally, the OS tries to prevent one process from accessing
another process's memory. Shared memory requires that two or more
processes agree to remove this restriction. They can then exchange
information by reading and writing data in the shared areas.
• Message passing is useful for exchanging smaller amounts of data,
because no conflicts need be avoided. It is also easier to implement than is
shared memory for intercomputer communication.
• Shared memory allows maximum speed and convenience of
communication, since it can be done at memory speeds when it
takes place within a computer. Problems exist, however, in the
areas of protection and synchronization between the processes
sharing memory.
• Functions:
• create, delete communication connection
• send, receive messages
• transfer status information
• Attach and Detach remote devices

You might also like