Os Bca Ii Unit 1
Os Bca Ii Unit 1
Os Bca Ii Unit 1
Introduction
What does OS do?
An Operating System (OS) is an interface between computer user and computer hardware.
An operating system is software which performs all the basic tasks like file management,
memory management, process management, handling input and output, and controlling
peripheral devices.
Some popular Operating Systems include Linux Operating System, Windows Operating System,
VMS, OS/400, AIX, z/OS, etc.
Definition – OS
A computer system has many resources (hardware and software), which may be required to
complete a task. The commonly required resources are input/output devices, memory, file
storage space, CPU, etc. The operating system acts as a manager of the above resources and
allocates them to specific programs and users, whenever necessary to perform a particular task.
Therefore the operating system is the resource manager i.e. it can manage the resource of a
computer system internally. The resources are processor, memory, files, and I/O devices. In
simple terms, an operating system is an interface between the computer user and the machine.
It is very important for you that every computer must have an operating system in order to run
other programs. The operating system mainly coordinates the use of the hardware among the
various system programs and application programs for various users.
1
In the above figure:
The Computer Hardware contains a central processing unit (CPU), the memory, and the
input/output (I/O) devices and it provides the basic computing resources for the system.
The Application programs like spreadsheets, Web browsers, word processors, etc. are
used to define the ways in which these resources are used to solve the computing
problems of the users. And the System program mainly consists of compilers, loaders,
editors, OS, etc.
The Operating System is mainly used to control the hardware and coordinate its use
among the various application programs for the different users.
Definition of OS is ---
An operating system is a program that acts as an interface between the user and the
computer hardware and controls the execution of all kinds of programs.
The operating system is a program that, when executed, controls the operation of the
computer.
The operating system can be observed from the point of view of the user or the system. This is
known as the user view and the system view respectively. More details about these are given as
follows –
User View
The user view depends on the system interface that is used by the users. The different types of
user view experiences can be explained as follows −
If the user is using a personal computer, the operating system is largely designed to make
the interaction easy. Some attention is also paid to the performance of the system, but
there is no need for the operating system to worry about resource utilization. This is
because the personal computer uses all the resources available and there is no sharing.
2
If the user is using a system connected to a mainframe or a minicomputer, the operating
system is largely concerned with resource utilization. This is because there may be
multiple terminals connected to the mainframe and the operating system makes sure that
all the resources such as CPU,memory, I/O devices etc. are divided uniformly between
them.
If the user is sitting on a workstation connected to other workstations through networks,
then the operating system needs to focus on both individual usage of resources and
sharing though the network. This happens because the workstation exclusively uses its
own resources but it also needs to share files etc. with other workstations across the
network.
If the user is using a handheld computer such as a mobile, then the operating system
handles the usability of the device including a few remote operations. The battery level of
the device is also taken into account.
There are some devices that contain very less or no user view because there is no interaction
with the users. Examples are embedded computers in home devices, automobiles etc.
System View
According to the computer system, the operating system is the bridge between applications and
hardware. It is most intimate with the hardware and is used to control it as required.
The different types of system view for operating system can be explained as follows:
The system views the operating system as a resource allocator. There are many resources
such as CPU time, memory space, file storage space, I/O devices etc. that are required by
processes for execution. It is the duty of the operating system to allocate these resources
judiciously to the processes so that the computer system can run as smoothly as possible.
The operating system can also work as a control program. It manages all the processes
and I/O devices so that the computer system works smoothly and there are no errors. It
makes sure that the I/O devices work in a proper manner without creating problems.
Operating systems can also be viewed as a way to make using hardware easier.
Computers were required to easily solve user problems. However it is not easy to work
directly with the computer hardware. So, operating systems were developed to easily
communicate with the hardware.
An operating system can also be considered as a program running at all times in the
background of a computer system (known as the kernel) and handling all the application
programs. This is the definition of the operating system that is generally followed.
3
Your computer's operating system (OS) manages all of the software and hardware on the
computer. Most of the time, there are several different computer programs running at the same
time, and they all need to access your computer's central processing unit (CPU), memory,
and storage. The operating system coordinates all of this to make sure each program gets what it
needs.
It mainly provides an interface between the computer hardware and the programmer that
simplifies and makes feasible for coding, creation of application programs and debugging
Important functions of an OS
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
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 part 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 −
4
Keeps tracks of all devices. 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 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.
5
Operating System as a Resource Manager
The Operating system of a Computer works as an inerface between he user, and hardware
devices. Applicaion software is designed to achieve specific tasks whereas the hardware helps in
achieving the task. The compuer system provides all this with the use of available resources. The
hard disk, primary memory and the processor can be though of as resources.
the Operating System provides an ordered and conrolled allocaion of the processor, memories
and I/O devices among he various programs.
Take for example, a computer system with a printer and two applications programs running. If
both programs wish to print a document at the same time, will those be printed by the printer or
will there be a contention? Here, the operating system comes into play: it manages to queue the
outputs to the printer. In short, this means that it is the ask of the operating system to manage a
computer's resources. Some of the resources that the operating system manages are:
Processor
Memory
Devices
Information
To explain simply:-
It manages the hardware and software resources of the system. In a desktop computer, these
resources include such things as the processor, memory, disk space and more (On a cell phone,
they include the keypad, the screen, the address book, the phone dialer, the battery and the
network connection).
It provides a stable, consistent way for applications to deal with the hardware without having to
know all the details of the hardware.
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.
1
De-allocates processor when a process is no longer required.
Device Management
Keeps tracks of all devices. 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 efficient way.
De-allocates devices.
Information 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.
2
The process, from its creation to completion, passes through various states. The minimum
number of states is five.
The names of the states are not standardized although the process may be in one of the following
states during execution.
1. New
A program which is going to be picked up by the OS into the main memory is called a new
process.
2. Ready
Whenever a process is created, it directly enters in the ready state, in which, it waits for the CPU
to be assigned. The OS picks the new processes from the secondary memory and put all of them
in the main memory.
The processes which are ready for the execution and reside in the main memory are called ready
state processes. There can be many processes present in the ready state.
3. Running
One of the processes from the ready state will be chosen by the OS depending upon the
scheduling algorithm. Hence, if we have only one CPU in our system, the number of running
processes for a particular time will always be one. If we have n processors in the system then we
can have n processes running simultaneously.
4. Block or wait
From the Running state, a process can make the transition to the block or wait state depending
upon the scheduling algorithm or the intrinsic behavior of the process.
When a process waits for a certain resource to be assigned or for the input from the user then the
OS move this process to the block or wait state and assigns the CPU to the other processes.
5. Completion or termination
When a process finishes its execution, it comes in the termination state. All the context of the
process (Process Control Block) will also be deleted the process will be terminated by the
Operating system.
6. Suspend ready
A process in the ready state, which is moved to secondary memory from the main memory due to
lack of the resources (mainly primary memory) is called in the suspend ready state.
If the main memory is full and a higher priority process comes for the execution then the OS
have to make the room for the process in the main memory by throwing the lower priority
process out into the secondary memory. The suspend ready processes remain in the secondary
memory until the main memory gets available.
7. Suspend wait
3
Instead of removing the process from the ready queue, it's better to remove the blocked process
which is waiting for some resources in the main memory. Since it is already waiting for some
resource to get available hence it is better if it waits in the secondary memory and make room for
the higher priority process. These processes complete their execution once the main memory gets
available and their wait is finished.
2. Scheduling
Out of the many processes present in the ready queue, the Operating system chooses one process
and start executing it. Selecting the process which is to be executed next, is known as scheduling.
3. Execution
Once the process is scheduled for the execution, the processor starts executing it. Process may
come to the blocked or wait state during the execution then in that case the processor starts
executing the other processes.
4. Deletion/killing
Once the purpose of the process gets over then the OS will kill the process. The Context of the
process (PCB) will be deleted and the process gets terminated by the Operating system.
Process Schedulers
Operating system uses various schedulers for the process scheduling described below.
Long Term scheduler mainly controls the degree of Multiprogramming. The purpose of long
term scheduler is to choose a perfect mix of IO bound and CPU bound processes among the jobs
present in the pool.
If the job scheduler chooses more IO bound processes then all of the jobs may reside in the
blocked state all the time and the CPU will remain idle most of the time. This will reduce the
degree of Multiprogramming. Therefore, the Job of long term scheduler is very critical and may
affect the system for a very long time.
4
A scheduling algorithm is used to select which job is going to be dispatched for the execution.
The Job of the short term scheduler can be very critical in the sense that if it selects job whose
CPU burst time is very high then all the jobs after that, will have to wait in the ready queue for a
very long time.
This problem is called starvation which may arise if the short term scheduler makes some
mistakes while selecting the job.
Medium term scheduler is used for this purpose. It removes the process from the running state to
make room for the other processes. Such processes are the swapped out processes and this
procedure is called swapping. The medium term scheduler is responsible for suspending and
resuming the processes.
It reduces the degree of multiprogramming. The swapping is necessary to have a perfect mix of
processes in the ready queue.
5
Operating System – Hierarchical View:
In hierarchical implementation, a given level is allowed to call upon services of lower levels, but
not on those of higher levels. For Ex. If we designed interposes message management module
that must call upon services of memory management module, the memory module must be in the
lower level than the message module, and must not call upon process message management. In
the figure below, this is shown by placing these modules at level 2 and 3 resp.
1
10/12/21, 10:59 AM Multiprocessor Systems
Multiprocessor Systems
Most computer systems are single processor systems i.e they only have one processor. However,
multiprocessor or parallel systems are increasing in importance nowadays. These systems have
multiple processors working in parallel that share the computer clock, memory, bus, peripheral
devices etc. An image demonstrating the multiprocessor architecture is −
Types of Multiprocessors
There are mainly two types of multiprocessors i.e. symmetric and asymmetric multiprocessors.
Details about them are as follows −
Symmetric Multiprocessors
In these types of systems, each processor contains a similar copy of the operating system and they
all communicate with each other. All the processors are in a peer to peer relationship i.e. no master -
slave relationship exists between them.
An example of the symmetric multiprocessing system is the Encore version of Unix for the Multimax
Computer.
Asymmetric Multiprocessors
In asymmetric systems, each processor is given a predefined task. There is a master processor that
gives instruction to all the other processors. Asymmetric multiprocessor system contains a master
slave relationship.
Asymmetric multiprocessor was the only type of multiprocessor available before symmetric
multiprocessors were created. Now also, this is the cheaper option.
In a multiprocessor system, even if one processor fails, the system will not halt. This ability to
continue working despite hardware failure is known as graceful degradation. For example: If there
are 5 processors in a multiprocessor system and one of them fails, then also 4 processors are still
working. So the system only becomes slower and does not ground to a halt.
Enhanced Throughput
If multiple processors are working in tandem, then the throughput of the system increases i.e.
number of processes getting executed per unit of time increase. If there are N processors then the
throughput increases by an amount just under N.
Multiprocessor systems are cheaper than single processor systems in the long run because they
share the data storage, peripheral devices, power supplies etc. If there are multiple processes that
share data, it is better to schedule them on multiprocessor systems with shared data than have
different computer systems with multiple copies of the data.
Increased Expense
Even though multiprocessor systems are cheaper in the long run than using multiple computer
systems, still they are quite expensive. It is much cheaper to buy a simple single processor system
than a multiprocessor system.
There are multiple processors in a multiprocessor system that share peripherals, memory etc. So, it
is much more complicated to schedule processes and impart resources to processes.than in single
processor systems. Hence, a more complex and complicated operating system is required in
multiprocessor systems.
All the processors in the multiprocessor system share the memory. So a much larger pool of
memory is required as compared to single processor systems.
https://www.tutorialspoint.com/Multiprocessor-Systems 2/2
OPERATING SYSTEM - SERVICES
http://www.tutorialspoint.com/operating_system/os_services.htm Copyright © tutorialspoint.com
An Operating System provides services to both the users and to the programs.
Program execution
I/O operations
Communication
Error Detection
Resource Allocation
Protection
Program execution
Operating system handles 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
I/O subsystem comprised of I/O devices and their corresponding driver software. Drivers hides the peculiarities of specific
hardware devices from the user as the device driver knows the peculiarities of the specific device.
Operating System manages the communication between user and device drivers. Following are the major activities of an
operating system with respect to I/O Operation.
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 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.
The operating system gives the permission to the program for operation on file.
Communication
In case of distributed systems which are a collection of processors that do not share memory, peripheral devices, or a clock,
operating system manages communications between processes. Multiple processes with one another through communication
lines in the network.
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.
The both processes can be on the one computer or on different computer but are connected through computer
network.
Communication may be implemented by two methods either by Shared Memory or by Message Passing.
Error handling
Error can occur anytime and anywhere. 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
In case of multi-user or multi-tasking environment, resources such as main memory, CPU cycles and files storage are to be
allocated to each user or job. Following are the major activities of an operating system with respect to resource
management.
Protection
Considering a computer systems having multiple users the concurrent execution of multiple processes, then the various
processes must be protected from each another's activities.
Protection refers to mechanism or a way to control the access of programs, processes, or users to the resources defined by a
computer systems. Following are the major activities of an operating system with respect to protection.
OS ensures that external I/O devices are protected from invalid access attempts.