Operating System
Operating System
Ability to Evolve: Execute user programs and make solving user problems easier.
Convenience: Make the computer system convenient to user.
Efficiency: Use the computer hardware in an efficient manner.
Components of Computer:
An operating system is an important part of almost every computer system. A computer system
can be divided roughly into four components: the hardware, the operating system, the
application programs, and the users.
1. Hardware – provides basic computing resources (CPU, memory, I/O devices).
2. Operating system – controls and coordinates the use of the hardware among the various
application programs for the various users.
3. Application programs – define the ways in which the system resources are used to solve the
computing problems of the users (compilers, database systems, video games, business
programs).
4. Users (people, machines, other computers).
Device Management:-An Operating System manages device communication via their respective
drivers. It does the following activities for device management −
Keeps track 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.
The list of Operating system services that are helpful to the user:
1. Program Execution
2. I/O Operation
3. File system manipulation
4. Communication
5. Error Detection
6. Resource allocation
7. Accounting
8. Protection and Security
The system must be able to load a program into memory and to run that program.
The program must be able to end its execution, either normally or abnormally (indicating
error).
2. I/O operations:
A running program may require I/O, which may involve a file or an I/O device.
For efficiency and protection, users usually cannot control I/O devices directly.
Therefore, the operating system must provide a means to do I/O.
3. File-system manipulation:
4. Communications:
There are many circumstances in which one process needs to exchange information
with another process.
Communications may be implemented via shared memory, in which two or more
processes read and write to a shared section of memory, or message passing, in which
packets of information in predefined formats are moved between processes by the
operating system.
5. Error detection:
6. Resource allocation:
When there are multiple users or multiple jobs running at the same time, resources
must be allocated to each of them.
The operating system manages many different types of resources.
For instance, in determining how best to use the CPU, operating systems have CPU-
scheduling routines that take into account the speed of the CPU, the jobs that must be
executed, the number of registers available, and other factors.
7. Accounting:
We want to keep track of which users use how much and what kinds of computer
resources.
This record keeping may be used for accounting (so that users can be billed) or simply
for accumulating usage statistics.
The owners of information stored in a multiuser or networked computer system may want
to control use of that information.
When several separate processes execute concurrently, it should not be possible for one
process to interfere with the others or with the operating system itself.
Protection involves ensuring that all access to system resources is controlled.
Security of the system from outsiders is also important. Such security starts with
requiring each user to authentication.
1. Batch Systems
2. Multiprogramming System
3. Time Sharing System
4. Parallel Systems
5. Real time Systems
6. Distributed Systems
7. PDA (Personal Digital Assistant)
1. Batch Systems:
In this type of system, there is no direct interaction between user and the computer.
The user has to submit a job (written on cards or tape) to a computer operator.
Then computer operator places a batch of several jobs on an input device.
Jobs are batched together by type of languages and requirement.
Then a special program, the monitor, manages the execution of each program in the
batch.
The monitor is always in the main memory and available for execution
The other jobs will have to wait for an unknown time if any job fails
2. Multiprogramming Systems:
In this, the operating system picks up and begins to execute one of the jobs from memory.
Once this job needs an I/O operation operating system switches to another job (CPU and
OS always busy).
Jobs in the memory are always less than the number of jobs on disk(Job Pool).
If several jobs are ready to run at the same time, then the system chooses which one to
run through the process of CPU Scheduling.
In Non-multiprogrammed system, there are moments when CPU sits idle and does not do
any work.
In Multiprogramming system, CPU will never be idle and keeps on processing.
Each task is given some time to execute so that all the tasks work smoothly.
Each user gets the time of CPU as they use a single system. These systems are also
known as Multitasking Systems. The task can be from a single user or different users
also. The time that each task gets to execute is called quantum. After this time interval
is over OS switches over to the next task.
4.Parallel Systems:
Many systems are single processor systems i.e., they have only one CPU. However,
Multiprocessor Systems (also known as Parallel Systems) have more than one processor in
close communication, sharing bus, the clock and sometimes memory and peripheral
devices. Hence, these systems can also be called “Tightly Coupled Systems”. The
advantages of parallel systems are
Increased throughput: The execution of the processes will be completed very fast
when compare with single processor system.
Economy of scale: Multiprocessor systems save money while compare to the
multiple single processor systems because sharing peripheral devices, memory,
secondary storage, common bus etc.,
Increased reliability: If we have ten processors and one fails, then each of the
remaining nine processors must pick up the share of a job and complete it. So the
system works with less speed.
6.Distributed System:
Various autonomous interconnected computers communicate with each other using a
shared communication network. Independent systems possess their own memory unit and
CPU. These are referred to as loosely coupled systems or distributed systems. These system’s
processors differ in size and function. The major benefit of working with these types of the
operating system is that it is always possible that one user can access the files or software
which are not actually present on his system but some other system connected within this
network i.e., remote access is enabled within the devices connected in that network.
In order to ensure the proper execution of the operating system, we must be able to
distinguish between the execution of operating-system code and user defined code.
At the very least, we need two separate modes of operation: user mode and kernel mode
B.V.Raju college, Vishnupur, Bhimavaram 10
Unit-1
With the mode bit, we can distinguish between a task that is executed on behalf of the
operating system and one that is executed on behalf of the user.
When the computer system is executing on behalf of a user application, the system is in
under user mode.
However, when a user application requests a service from the operating system (via a
system call), the system must transition from user to kernel mode to fulfill the request.
Kernel Mode:
When CPU is in kernel mode, the code being executed can access any memory address
and any hardware resource.
Hence kernel mode is a very privileged and powerful mode.
If a program crashes in kernel mode, the entire system will be halted.
User Mode:
When CPU is in user mode, the programs don’t have direct access to memory and
hardware resources.
In user mode, if any program crashes, only that particular program is halted.
That means the system will be in a safe state even if a program in user mode crashes.
Hence, most programs in an OS run in user mode.
Kernel:
Kernel is the part of the operating system, it interacts directly with the hardware of a
computer, through device that is build into the kernel. The main functions of the kernel are to
manage computer memory, to control access to the computer, to maintain the file system, to
handle interrupts, to handle errors, to perform input and output services, and to allocate the
resources of the computer among users.
USERR
SYSTEM CALLS:
System call: When a program in user mode requires access to RAM or a hardware resource,
it must ask the kernel to provide access to that resource. This is done via something called
a system call. System calls provide an interface between a process and the operating system.
B.V.Raju college, Vishnupur, Bhimavaram 12
Unit-1
When a program makes a system call, the mode is switched from user mode to kernel mode. This
is called a context switch. These calls are generally available as routines written in C and C++.
Generally, system calls are made by the user level programs in the following situations:
Creating, opening, closing and deleting files in the file system.
Creating and managing new processes.
Creating a connection in the network, sending and receiving packets.
Requesting access to a hardware device, like a mouse or a printer.
fig. The handling of a user application invoking the open() system call
Types of System Calls:
There are mainly five types of system calls. They are:
1. Process control
2. File manipulation
3. Device manipulation
4. Information maintenance
5. Communications
1. Process Control:
wait event( ) After creating new processes, it may need to wait for a certain
amount of time to pass to finish its execution.
signal event( ): The jobs or processes signals when an event has occurred.
get process attributes( ) and set process attributes( ) are used to control execution
of a process.
2. File Management:
3. Device Management :
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 of the operating system, the amount of free memory
or disk space, and so on.
5. Communication:
System Programs:
System programs are also known as system utilities provide a more convenient environment
for program development and execution. The system programs can be divided into several
categories:
1. File Manipulation: These programs create, delete, copy, rename, print, dump, list, and
generally manipulate files and directories.
2. Status information: Some programs simply ask the system for the date, time, amount of
available memory or disk space, number of users, or similar status information. That
information is then formatted, and is printed to the terminal or other output device or file.
3. File modification: Several text editors may be available to create and modify the content
of files stored on disk or tape.
1. Simple Structure:
There are several commercial systems that don‘t have a well- defined structure such
operating systems begin as small, simple & limited systems and then grow beyond
their original scope.
MS-DOS (Microsoft Disk Operating System) is an example of such system. It was
not divided into modules carefully. In MS-DOS, the interfaces and levels of
functionality are not well separated.
So MS-DOS was vulnerable to malicious programs, causing the entire system to
crash when user programs fail.
Another example of limited structuring is the UNIX operating system.
2. Layered Approach:
In the layered approach, the OS is broken into a number of layers (levels) each built on
top of lower layers. The bottom layer (layer 0) is the hardware & top most layer
(layer N) is the user interface.
The main advantage of the layered approach is modularity.
The layers are selected such that each uses functions (or operations) & services of
only lower layer.
This approach simplifies debugging & system verification, i.e. the first layer can be
debugged without concerning the rest of the system. Once the first layer is
debugged, its correct functioning is assumed while the 2nd layer is debugged & so
on.
If an error is found during the debugging of a particular layer, the error must be on
that layer because the layers below it are already debugged. Thus the design &
implementation of the system are simplified when the system is broken down into
layers.
The layer approach was first used in the operating system. It was defined in six layers.
The major difficulty with the layered approach involves appropriately defining the
various layers. Because a layer can use only lower-level layers, careful planning is
necessary.
Layers Functions
5 User Program
4 I/O Management
3 Process Communication
2 Memory Management
1 CPU Scheduling
0 Hardware
3. Micro-kernel Approach:
In the UNIX operating system, the kernel became large and it is difficult to manage.
But in the microkernel approach, all non essential components are removed from
kernel and implementing them as system and user-level programs that creates a smaller
kernel. The benefits of microkernel is
easier to extend a microkernel
easier to port the operating system to new architectures
more reliable (less code is running in kernel mode)