Unit 1 Notes - Operating System
Unit 1 Notes - Operating System
Unit 1 Notes - Operating System
Evolution of OS since 1950 described in detail in this article. Here we will discuss six main
operating system types evaluated over the past 70 years.
Distributed System
Serial Processing
History of the operating system started in 1950. Before 1950, the programmers directly interact
with the hardware there was no operating system at that time. If a programmer wishes to
execute a program on those days, the following serial steps are necessary.
• Type the program or punched card.
• Convert the punched card to a card reader.
• submit to the computing machine, is there any errors, the error was indicated by the
lights.
• The programmer examined the register and main memory to identify the cause of an
error
• Take outputs on the printers.
• Then the programmer ready for the next program.
Drawback:
This type of processing is difficult for users, it takes much time and the next program should
wait for the completion of the previous one. The programs are submitted to the machine one
after one, therefore the method is said to be serial processing.
Batch Processing
Before 1960, it is difficult to execute a program using a computer because of the computer
located in three different rooms, one room for the card reader, one room for executing the
program and another room for printing the result.
The user/machine operator runs between three rooms to complete a job. We can solve this
problem by using batch processing.
In batch processing technique, the same type of jobs batch together and execute at a time. The
carrier carries the group of jobs at a time from one room to another.
Therefore, the programmer need not run between these three rooms several times.
Multiprogramming
Multiprogramming is a technique to execute the number of programs simultaneously by a single
processor. In multiprogramming, a number of processes reside in main memory at a time. The
OS(Operating System) picks and begins to execute one of the jobs in main memory. Consider
the following figure, it depicts the layout of the multiprogramming system. The main memory
consisting of 5 jobs at a time, the CPU executes one by one.
In the non-multiprogramming system, the CPU can execute only one program at a time, if the
running program is waiting for any I/O device, the CPU becomes idle so it will effect on the
performance of the CPU.
But in a multiprogramming environment, if any I/O wait happened in a process, then the CPU
switches from that job to another job in the job pool. So, the CPU is not idle at any time.
Advantages:
• Can get efficient memory utilization.
• CPU is never idle so the performance of CPU will increase.
• The throughput of CPU may also increase.
• In the non-multiprogramming environment, the user/program has to wait for CPU much
time. But waiting time is limited in multiprogramming.
Time Sharing System
Time-sharing or multitasking is a logical extension of multiprogramming. Multiple jobs are
executed by the CPU switching between them. The CPU scheduler selects a job from the ready
queue and switches the CPU to that job. When the time slot expires, the CPU switches from this
job to another.
In this method, the CPU time is shared by different processes. So, it is said to be "Time-Sharing
System". Generally, time slots are defined by the operating system.
Advantages:
• The main advantage of the time-sharing system is efficient CPU utilization. It was
developed to provide interactive use of a computer system at a reasonable cost. A time shared
OS uses CPU scheduling and multiprogramming to provide each user with a small portion of a
time-shared computer.
• Another advantage of the time-sharing system over the batch processing system is, the
user can interact with the job when it is executing, but it is not possible in batch systems.
Parallel System
There is a trend multiprocessor system, such system have more than one processor in close
communication, sharing the computer bus, the clock, and sometimes memory and peripheral
devices.
These systems are referred to as "Tightly Coupled" system. Then the system is called a parallel
system. In the parallel system, a number of processors are executing there job in parallel.
Advantages:
• It increases the throughput.
• By increasing the number of processors(CPU), to get more work done in a shorter period
of time.
Distributed System
In a distributed operating system, the processors cannot share a memory or a clock, each
processor has its own local memory. The processor communicates with one another through
various communication lines, such as high-speed buses. These systems are referred to as
"Loosely Coupled" systems.
Advantages:
• If a number of sites connected by high-speed communication lines, it is possible to share
the resources from one site to another site, for example, s1 and s2 are two sites. These are
connected by some communication lines. The site s1 having a printer, but the site does not have
any print. Then the system can be altered without moving from s2 to s1. Therefore, resource
sharing is possible in the distributed operating system.
• A big computer that is partitioned into a number of partitions, these sub-partitions are run
concurrently in distributed systems.
• If a resource or a system fails in one site due to technical problems, we can use other
systems/resources in some other sites. So, the reliability will increase in the distributed system.
Real Time System : There is also a Operating System which is known as Real Time Processing
System. In this Response Time is already fixed. Means time to Display the Results after
Possessing has fixed by the Processor or CPU.
Real Time System is used at those Places in which we Requires higher and Timely Response.
These Types of Systems are used in Bomb and Reservation. So when we Specify the Request,
the CPU will Perform at that Time. There are two Types of Real Time System
A Hard Real-Time System guarantees that critical tasks complete on time. This goal requires
that all delays in the system be bounded from the retrieval of the stored data to the time that it
takes the operating system to finish any request made of it.
A Soft Real Time System where a critical real-time task gets priority over other tasks and
retains that priority until it completes. As in hard real time systems kernel delays need to be
bounded.
Program execution
I/O operations
File System manipulation
Communication
Error Detection
Resource Allocation
Protection
Program execution
Operating systems handle many kinds of activities from user programs to system programs like
printer spooler, name servers, file server, etc. Each of these activities is encapsulated as a
process.
A process includes the complete execution context (code to execute, data to manipulate,
registers, OS resources in use). Following are the major activities of an operating system with
respect to program management −
I/O Operation
An I/O subsystem comprises of I/O devices and their corresponding driver software. Drivers
hide the peculiarities of specific hardware devices from the users.
An Operating System manages the communication between user and device drivers.
I/O operation means read or write operation with any file or any specific I/O device.
Operating system provides the access to the required I/O device when required.
A file represents a collection of related information. Computers can store files on the disk
(secondary storage), for long-term storage purpose. Examples of storage media include
magnetic tape, magnetic disk and optical disk drives like CD, DVD. Each of these media has its
own properties like speed, capacity, data transfer rate and data access methods.
A file system is normally organized into directories for easy navigation and usage. These
directories may contain files and other directions. Following are the major activities of an
operating system with respect to file management −
Communication
In case of distributed systems which are a collection of processors that do not share memory,
peripheral devices, or a clock, the operating system manages communications between all the
processes. Multiple processes communicate with one another through communication lines in
the network.
The OS handles routing and connection strategies, and the problems of contention and security.
Following are the major activities of an operating system with respect to communication −
Error handling
Errors can occur anytime and anywhere. An error may occur in CPU, in I/O devices or in the
memory hardware. Following are the major activities of an operating system with respect to
error handling −
Resource Management
Protection
Considering a computer system having multiple users and concurrent execution of multiple
processes, the various processes must be protected from each other's activities.
Protection refers to a mechanism or a way to control the access of programs, processes, or users
to the resources defined by a computer system. Following are the major activities of an
operating system with respect to protection −
Batch processing
Batch processing is a technique in which an Operating System collects the programs and data
together in a batch before processing starts. An operating system does the following activities
related to batch processing −
The OS defines a job which has predefined sequence of commands, programs and data as
a single unit.
The OS keeps a number a jobs in memory and executes them without any manual
information.
Jobs are processed in the order of submission, i.e., first come first served fashion.
When a job completes its execution, its memory is released and the output for the job
gets copied into an output spool for later printing or processing.
Advantages
Batch processing takes much of the work of the operator to the computer.
Increased performance as a new job get started as soon as the previous job is finished,
without any manual intervention.
Disadvantages
Multitasking
Multitasking is when multiple jobs are executed by the CPU simultaneously by switching
between them. Switches occur so frequently that the users may interact with each program
while it is running. An OS does the following activities related to multitasking −
The user gives instructions to the operating system or to a program directly, and receives
an immediate response.
The OS handles multitasking in the way that it can handle multiple operations/executes
multiple programs at a time.
Multitasking Operating Systems are also known as Time-sharing systems.
These Operating Systems were developed to provide interactive use of a computer
system at a reasonable cost.
A time-shared operating system uses the concept of CPU scheduling and
multiprogramming to provide each user with a small portion of a time-shared CPU.
Each user has at least one separate program in memory.
A program that is loaded into memory and is executing is commonly referred to as
a process.
When a process executes, it typically executes for only a very short time before it either
finishes or needs to perform I/O.
Since interactive I/O typically runs at slower speeds, it may take a long time to complete.
During this time, a CPU can be utilized by another process.
The operating system allows the users to share the computer simultaneously. Since each
action or command in a time-shared system tends to be short, only a little CPU time is
needed for each user.
As the system switches CPU rapidly from one user/program to the next, each user is
given the impression that he/she has his/her own CPU, whereas actually one CPU is
being shared among many users.
Multiprogramming
Sharing the processor, when two or more programs reside in memory at the same time, is
referred as multiprogramming. Multiprogramming assumes a single shared processor.
Multiprogramming increases CPU utilization by organizing jobs so that the CPU always has
one to execute.
The following figure shows the memory layout for a multiprogramming system.
Advantages
Disadvantages
Interactivity
Interactivity refers to the ability of users to interact with a computer system. An Operating
system does the following activities related to interactivity −
Real-time systems are usually dedicated, embedded systems. An operating system does the
following activities related to real-time system activity.
In such systems, Operating Systems typically read from and react to sensor data.
The Operating system must guarantee response to events within fixed periods of time to
ensure correct performance.
Distributed Environment
Spooling
Advantages
System programs provide an environment where programs can be developed and executed. In the
simplest sense, system programs also provide a bridge between the user interface and system
calls. In reality, they are much more complex. For example, a compiler is a complex system
program.
System Programs Purpose
The system program serves as a part of the operating system. It traditionally lies between the
user interface and the system calls. The user view of the system is actually defined by system
programs and not system calls because that is what they interact with and system programs are
closer to the user interface.
An image that describes system programs in the operating system hierarchy is as follows −
In the above image, system programs as well as application programs form a bridge between the
user interface and the system calls. So, from the user view the operating system observed is
actually the system programs and not the system calls.
Types of System Programs
System programs can be divided into seven parts. These are given as follows:
Status Information
The status information system programs provide required data on the current or past status of the
system. This may include the system date, system time, available memory in system, disk space,
logged in users etc.
Communications
These system programs are needed for system communications such as web browsers. Web
browsers allow systems to communicate and access information from the network as required.
File Manipulation
These system programs are used to manipulate system files. This can be done using various
commands like create, delete, copy, rename, print etc. These commands can create files, delete
files, copy the contents of one file into another, rename files, print them etc.
Program Loading and Execution
The system programs that deal with program loading and execution make sure that programs can
be loaded into memory and executed correctly. Loaders and Linkers are a prime example of this
type of system programs.
File Modification
System programs that are used for file modification basically change the data in the file or
modify it in some other way. Text editors are a big example of file modification system
programs.
Application Programs
Application programs can perform a wide range of services as per the needs of the users. These
include programs for database systems, word processors, plotting tools, spreadsheets, games,
scientific applications etc.
Programming Language Support
These system programs provide additional support features for different programming languages.
Some examples of these are compilers, debuggers etc. These compile a program and make sure it
is error free respectively.
The interface between a process and an operating system is provided by system calls. In
general, system calls are available as assembly language instructions. They are also
included in the manuals used by the assembly level programmers. System calls are usually
made when a process in user mode requires access to a resource. Then it requests the
kernel to provide the resource via a system call.
A system call is a mechanism that provides the interface between a process and the operating
system. It is a programmatic method in which a computer program requests a service from the
kernel of the OS.System call offers the services of the operating system to the user programs via
API (Application Programming Interface). System calls are the only entry points for the kernel
system.
System Calls in Operating System
For example if we need to write a program code to read data from one file, copy that data into
another file. The first information that the program requires is the name of the two files, the input
and output files.
In an interactive system, this type of program execution requires some system calls by OS.
Step 1) The processes executed in the user mode till the time a system call interrupts it.
Step 2) After that, the system call is executed in the kernel-mode on a priority basis.
Step 3) Once system call execution is over, control returns to the user mode.,
Process Control
File Management
Device Management
Information Maintenance
Communications
Process Control
This system calls perform the task of process creation, process termination, etc.
Functions:
File Management
File management system calls handle file manipulation jobs like creating a file, reading, and
writing, etc.
Functions:
Create a file
Delete file
Open and close file
Read, write, and reposition
Get and set file attributes
Device Management
Device management does the job of device manipulation like reading from device buffers,
writing into device buffers, etc.
Functions
Information Maintenance
It handles information and its transfer between the OS and the user program.
Functions:
Communication:
These types of system calls are specially used for interprocess communications.
Functions:
wait()
In some systems, a process needs to wait for another process to complete its execution. This type
of situation occurs when a parent process creates a child process, and the execution of the parent
process remains suspended until its child process executes.
The suspension of the parent process automatically occurs with a wait() system call. When the
child process ends execution, the control moves back to the parent process.
fork()
Processes use this system call to create processes that are a copy of themselves. With the help of
this system Call parent process creates a child process, and the execution of the parent process
will be suspended till the child process executes.
exec()
This system call runs when an executable file in the context of an already running process that
replaces the older executable file. However, the original process identifier remains as a new
process is not built, but stack, data, head, data, etc. are replaced by the new process.
kill():
The kill() system call is used by OS to send a termination signal to a process that urges the
process to exit. However, a kill system call does not necessarily mean killing the process and can
have various meanings.
exit():
The exit() system call is used to terminate program execution. Specially in the multi-threaded
environment, this call defines that the thread execution is complete. The OS reclaims resources
that were used by the process after the use of exit() system call.
When we run different processes on an operating system, it creates an illusion that each process
is running on a different processor having its own virtual memory, with the help of CPU
scheduling and virtual-memory techniques. There are additional features of a process that cannot
be provided by the hardware alone like system calls and a file system. The virtual machine
approach does not provide these additional functionalities but it only provides an interface that is
same as basic hardware. Each process is provided with a virtual copy of the underlying computer
system.
We can create a virtual machine for several reasons, all of which are fundamentally related to the
ability to share the same basic hardware yet can also support different execution environments,
i.e., different operating systems simultaneously.
The main drawback with the virtual-machine approach involves disk systems. Let us suppose
that the physical machine has only three disk drives but wants to support seven virtual machines.
Obviously, it cannot allocate a disk drive to each virtual machine, because virtual-machine
software itself will need substantial disk space to provide virtual memory and spooling. The
solution is to provide virtual disks.
Users are thus given their own virtual machines. After which they can run any of the operating
systems or software packages that are available on the underlying machine. The virtual-machine
software is concerned with multi-programming multiple virtual machines onto a physical
machine, but it does not need to consider any user-support software. This arrangement can
provide a useful way to divide the problem of designing a multi-user interactive system, into two
smaller pieces.
Advantages:
1. There are no protection problems because each virtual machine is completely isolated
from all other virtual machines.
2. Virtual machine can provide an instruction set architecture that differs from real
computers.
3. Easy maintenance, availability and convenient recovery.
Disadvantages:
1. When multiple virtual machines are simultaneously running on a host computer, one
virtual machine can be affected by other running virtual machines, depending on the
workload.
2. Virtual machines are not as efficient as a real one when accessing the hardware.