Operating System
Operating System
Introduction
An operating system acts as an intermediary between the user of a computer and computer
hardware. The purpose of an operating system is to provide an environment in which a user can
execute programs in a convenient and efficient manner. An operating system is a software that
manages the computer hardware. The hardware must provide appropriate mechanisms to ensure
the correct operation of the computer system and to prevent user programs from interfering with
the proper operation of the system.
Operating System – Definition: An operating system is a program that controls the execution of
application programs and acts as an interface between the user of a computer and the computer
hardware. A more common definition is that the operating system is the one program running at
all times on the computer (usually called the kernel), with all else being application programs. An
operating system is concerned with the allocation of resources and services, such as memory,
processors, devices, and information. The operating system correspondingly includes programs to
manage these resources, such as a traffic controller, a scheduler, memory management module,
I/O programs, and a file system.
1
Operating system performs the following functions:
1. Process Management: A program does nothing unless their instructions are executed by
a CPU. A process is a program in execution. A time shared user program such as a complier
is a process. A word processing program being run by an individual user on a pc is a
process. A system task such as sending output to a printer is also a process. A process needs
certain resources including CPU time, memory files & I/O devices to accomplish its task.
2. Booting: Booting is a process of starting the computer operating system starts the computer
to work. It checks the computer and makes it ready to work.
3. Memory Management: It is also an important function of operating system. The memory
cannot be managed without operating system. Different programs and data execute in
memory at one time. if there is no operating system, the programs may mix with each other.
The system will not work properly.
4. Loading and Execution: A program is loaded in the memory before it can be executed.
Operating system provides the facility to load programs in memory easily and then execute
it.
5. Data security Data is an important part of computer system. The operating system protects
the data stored on the computer from illegal use, modification or deletion.
6. Disk Management: Operating system manages the disk space. It manages the stored files
and folders in a proper way.
2
7. Device controlling: operating system also controls all devices attached to computer. The
hardware devices are controlled with the help of small software called device drivers..
8. Providing interface: It is used in order that user interface acts with a computer mutually.
User interface controls how you input data and instruction and how information is
displayed on screen.
Early computers were physically large machine. The common input devices were card readers,
tape drivers. The common output devices were line printers, tape drivers and card punches. In these
systems the user did not interact directly with the computer system. Instead the user preparing a
job which consists of programming data and some control information and then submitted it to the
computer 7 | P a g e operator after some time the output is appeared. The output in these early
computer was fairly simple is main task was to transfer control automatically from one job to next.
The operating system always resides in the memory. To speed up processing operators batched the
jobs with similar needs and ran then together as a group.
2.
3
3.
The time sharing system is also known as multi user systems. The CPU executes multiple jobs by
switching among them but the switches occurs so frequently that the user can interact with each
program while it is running. An interactive computer system provides direct communication
between a user and system. The user gives instruction to the operating systems or to a program
directly using keyboard or mouse and wait for immediate results. So the response time will be
short. The time sharing system allows many users to share the computer simultaneously.
Real time system is used when there are rigid time requirements on the operation of a processor or
flow of data. Sensors bring data to the computers. The computer analyzes data and adjusts controls
4
to modify the sensors inputs. System that controls scientific experiments, medical imaging systems
and some display systems are real time systems
System structure deals with how the components of an operating system interconnected. The
following are some of the existing structures.
1. Simple structure: There are several commercial system that don’t have a well- defined
structure such operating systems begins as small, simple & limited systems and then grow
beyond their original scope. MS-DOS is an example of such system. It was not divided
into modules carefully. Another example of limited structuring is the UNIX operating
system.
2. Monolithic Structure: is an architecture where the operating system is working in the kernel
space.
5
The kernel is the core component of the operating system. It handles the management of
low-level hardware resources, including memory, processors, and input/output (I/O)
devices, such as a keyboard, mouse, or video display.
3. Layered Approach: In layered approach, the operating system is broken into a number of
layers (levels). The bottom layer (layer 0) is the hardware, the highest (layer N) is the user
interface. An operating system layer is an implementation of an abstract object made up of
data and the operations that can manipulate those data. A typical operating system layer
say, layer M consists of data structures and a set of routines that can be invoked by higher
level layers. Layer M, in turn, can invoke operations on lower level layers.
6
Process State
What is a Process In computing? A process is the instance of a computer program that is being
executed by one or many threads. It contains the program code and its activity. Depending on the
operating system (OS), a process may be made up of multiple threads of execution that execute
instructions concurrently. While a computer program is a passive collection of instructions, a
process is the actual execution of those instructions. Several processes may be associated with the
same program; for example, opening up several instances of the same program often results in
more than one process being executed.
Process States: When a process executed, it changes the state, generally the state of process is
determined by the current activity of the process. Each process may be in one of the following
states:
Only one process can be running in any processor at any time, but many process may be in ready
and waiting states. The ready processes are loaded into a “ready queue”
7
a) New ->Ready: OS creates process and prepares the process to be executed, then OS moved
the process into ready queue.
b) Ready->Running: OS selects one of the Jobs from ready Queue and move them from ready
to Running.
c) Running->Terminated: When the Execution of a process has Completed, OS terminates
that process from running state. Sometimes OS terminates the process for some other
reasons including Time exceeded, memory unavailable, access violation, protection Error,
I/O failure and soon.
d) Running->Ready: When the time slot of the processor expired (or) If the processor received
any interrupt signal, the OS shifted Running -> Ready State.
e) Running -> Waiting: A process is put into the waiting state, if the process need an event
occur (or) an I/O Device require.
f) Waiting->Ready: A process in the waiting state is moved to ready state when the event for
which it has been Completed.
Dispatching
Dispatching is a module responsible for context switching. Context switching is the process of
saving the context of one process and loading the context of another process is known as Context
Switching. In simple terms, it is like loading and unloading the process from running state to ready
state.
1. When a high-priority process comes to ready state (i.e. with higher priority than the running
process)
2. An Interrupt occurs
8
Interrupts
Concurrency
Concurrency is the execution of a set of multiple instruction sequences at the same time. This
occurs when there are several process threads running in parallel. These threads communicate with
the other threads/processes through a concept of shared memory or through message passing.
Because concurrency results in the sharing of system resources - instructions, memory, files -
problems can occur. Like deadlocks and resources starvation. (
Starvation
Deadlock
A deadlock is a state in which each member of a group waits for another member, including itself,
to take action, such as sending a message or more commonly releasing a lock. Deadlocks are a
common problem in multiprocessing systems, parallel computing, and distributed systems, where
software and hardware locks are used to arbitrate shared resources and implement process
synchronization.
9
Mutual Exclusion
The problem which mutual exclusion addresses is a problem of resource sharing: how can a
software system control multiple processes' access to a shared resource, when each process needs
exclusive control of that resource while doing its work? The mutual-exclusion solution to this
makes the shared resource available only while the process is in a specific code segment called the
critical section. It controls access to the shared resource by controlling each mutual execution of
that part of its program where the resource would be used.
10