OS (Unit 1)
OS (Unit 1)
Unit-1 Syllabus
Calls, Types, Operating System Structure, System Boot Processes: Process Concept,
The basic organization of a computer system is the processing unit, memory unit,
and input-output devices. The processing unit controls all the functions of the
computer system. It is the brain of the computer e.g. CPU. The memory unit
consists of two units.
2. Memory Unit
A memory is just like a human brain. It is used to store data and instruction. Computer
memory is use to Stores information being processed by the CPU
3. Control Unit
Control unit help to perform operations of input unit, output unit, Memory unit and ALU
in a sequence.
Memory
Computer memory is any physical device capable of storing information temporarily or
permanently. For example, Random Access Memory RAM is a type of volatile memory
that is stores information on an integrated circuit, and that is used by the operating system,
software, hardware, or the user.
1. Volatile memory
Volatile memory is a temporary memory that loses its contents when the computer
or hardware device loses power.eg. RAM
2. Non-volatile memory
Non-volatile memory keeps its contents even if the power is lost. Example: ROM or
EPROM is a good example of a non-volatile memory
Input Devices
A device that can be used to insert data into a computer system is called as input device.
It allows people to supply information to computers. An input device is any hardware
device that sends data to the computer, without any input devices, a computer would
only be a display device and not allow users to interact with it, much like a TV.The
most fundamental pieces of information are keystrokes on a keyboard and clicks with a
mouse. These two input devices are essential for you to interact with your computer.
Input devices represent one type of computer peripheral.
Examples of input devices include keyboards, mouse, scanners, digital cameras and
joysticks.
Output Devices
A device which is used to display result from a computer is called as output device.
It Allows people to receive information from computers. An output device is any
peripheral that receives or displays output from a computer. The picture shows an inkjet
printer, an output device that can make a hard copy of anything being displayed on a
monitor. Output device is electronic equipment connected to a computer and used to
transfer data out of the computer in the form of text, images, sounds or print.
Examples of output devices include Printer, Scanner, Monitor, etc.
The OS helps you to communicate with the computer without knowing how to
speak the computer's language. It is not possible for the user to use any
computer or mobile device without having an operating system.
The user of a batch operating system never directly interacts with the
computer. In this type of OS, every user prepares his or her job on an offline
device like a punch card and submit it to the computer operator.
The batch operating system grouped jobs that perform similar functions. These job
groups are treated as a batch and executed simultaneously. A computer system with this
operating system performs the following batch processing activities:
Advantages
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.
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
The following figure shows the memory layout for a multiprogramming system.
Advantages
High and efficient CPU utilization.
User feels that many programs are allotted CPU almost
simultaneously.
Increases resource utilisation
Disadvantages
A multi-user operating system is an operating system that permits several users to access
a single system running to a single operating system. It is a logical extension of Multi
programming. The system switches rapidly form one user to the next. The user is given
an impression that entire system is dedicated to one user. Users will usually sit at
terminals or computers connected to the system via a network and other system machines
like printers.
Distributed System
Distributed systems use many processors located in different machines to
provide very fast computation to its users.
A distributed System refers to multiple independent CPUs or processors in a
computer system. An operating system does the following activities related to
distributed environment −
The OS distributes work(Computation) among several physical
processors.
The processors do not share memory or a clock. Instead, each
processor has its own local memory.
Disadvantages
Costly setup
If server is failed ,then the whole system will fail.
File Table
The file table contains entries about all the files in the system. If two or more processes
use the same file, then they contain the same file information and the file descriptor
number.
Each file table entry contains information about the file such as file status (file read or
file write), file offset etc. The file offset specifies the position for next read or write
into the file.
The file table also contains v-node and i-node pointers which point to the virtual node
and index node respectively. These nodes contain information on how to read a file.
V- Node and I-Node Tables
Both the v-node and i-node are references to the storage system of the file and the
storage mechanisms. They connect the hardware to the software.
The v-node is an abstract concept that defines the method to access file data without
worrying about the actual structure of the system. The i-node specifies file access
information like file storage device, read/write procedures etc.
Computing Environments
Computing environment is a collection of computers/machines arranged in different ways to
solve many problems. This constitutes a computing environment where many computers are
used to process and exchange information to handle multiple issues.
Types of computing environments
There are four types of computing environments. They are:
Client/Server is a distribute computing model, in which the client requests services from
the server.
Client/Server usually run on separate computers connected by a network.
A client is a process or an application that sends messages to a server through the
network.
These messages ask the server to perform a specific task, like finding a customer record
in a database.
Severs usually run on powerful computers, workstations or mainframes
The administration of the installed equipment is more expensive than maintaining a
centralized system
Program execution
I/O operations
File System manipulation Communication
Error Detection
Resource Allocation
Protection
Program execution
I/O Operation
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
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.
Types of System calls
Here are the five types of system calls used in OS:
Process Control
File Management
Device Management
Information Maintenance
Communications
Process Control
This system calls perform the task of process creation, process
termination, etc.
Functions:
End and Abort Load and Execute
Create Process and Terminate Process
Wait and Signal Event
Allocate and free memory
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, replace
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
Request and release device
Logically attach devices
Logically detach devices
Get and Set device attributes
Information Maintenance
It handles information and its transfer between the OS and the user program.
Functions:
Get or set time and date
Get process and device attributes
Communication:
These types of system calls are specially used for inter process
communications.
Functions:
Create, delete communications connections
Send, receive message
Help OS to transfer status information
Attach or detach remote devices
Process management
Process
Process can be defined as program under execution. Program becomes a
process when it’s executable file is loaded into the memory. A process is an
instance of program execution.
States of Process:
Waiting : When process waits for a resource input file or output file
For each process there is a Process Control Block, PCB, which stores the following (
types of )
process-specific information, Process State - Running, waiting, etc., as discussed
above.
Process ID, and parent process ID - It will uniquely identify the process.
CPU registers and Program Counter - These need to
be saved and restored when swapping processes in and
out of the CPU.
CPU-Scheduling information - Such as priority
information and pointers to scheduling queues.
Memory-Management information - E.g. page tables or segment tables.
Accounting information - user and kernel CPU time
consumed, account numbers, limits,etc.
I/O Status information - Devices allocated, open file tables, etc.
Process Scheduling
The two main objectives of the process scheduling system are to keep the CPU
busy always Scheduling Queues
All processes are stored in the job queue.
Processes in the Ready state are placed in the ready queue.
Processes waiting for a device to become available or to
deliver data are placed in device queues. There is generally
a separate device queue for each device.
Other queues may also be created and used as needed.
Schedulers
The process migrates among various queues in their life time. The OS has
to select the process for scheduling purpose. The selection is done by
module called scheduler.There are 3 types of scheduler.
3. medium-term scheduler.
When system loads get high, this scheduler will swap one or more
processes out of the ready queue system for a few seconds, in order
to allow smaller faster jobs to finish up quickly and clear the system.
See the differences in Figures 3.7 and 3.8 below.
It is in charge of suspended to ready transition.
The frequency of invocation is in between the remaining two types.
Types of Scheduling
2) pre-emptive Scheduling: Once the CPU is given to a process it can not be taken
away
from that process.
priority process
maystarve.
CPUutilization is scheduling.
high.
andShortest First
Context Switch
Co-operating processes
In the computer system, there are many processes which may be either independent
processes or
cooperating processes that run in the operating system.
There are several reasons for providing an environment that allows process
cooperation:
Information sharing
In the information sharing at the same time, many users may want the same
piece of information(for instance, a shared file) and we try to provide that
environment in which the users are allowed to concurrent access to these types
of resources.
Computation speedup
When we want a task that our process run faster so we break it into a subtask,
and each subtask will be executing in parallel with another one. It is noticed
that the speedup can be achieved only
if the computer has multiple processing elements (such as CPUs or I/O channels).
modularity
In the modularity, we are trying to construct the system in such a modular
fashion, in which the system dividing its functions into separate processes.
Convenience
An individual user may have many tasks to perform at the same time and
the user is able to do his work like editing, printing and compiling.
Thread
Benefits of Multithreading
1. Responsiveness
2. Resource sharing, hence allowing better utilization of resources.
3. Economy. Creating and managing threads becomes easier.
Different CPU scheduling algorithms have different properties and the choice
of a particular algorithm depends on the various factors. Many criteria have
been suggested for comparing CPU scheduling algorithms.
The criteria include the following:
1. CPU utilization –
The main objective of any CPU scheduling algorithm is to keep the
CPU as busy as possible. Theoretically, CPU utilization can range from
0 to 100 but in a real-time system, it varies from 40 to 90 percent
depending on the load upon the system.
2. Throughput –
A measure of the work done by CPU is the number of processes being
executed and completed per unit time. This is called throughput. The
throughput may vary depending upon the length or duration of
processes. Eg 10process/Second,5process/1 hour
3. Turnaround time –
For a particular process, an important criteria is how long it takes to
execute that process. The time elapsed from the time of submission of a
process to the time of completion is known as the turnaround time.
Turnaround Time = Waiting Time + Execution Time
4. Waiting time –
A scheduling algorithm does not affect the time required to complete
the process once it starts execution. It only affects the waiting time
of a process i.e. time spent by a process waiting in the ready queue.
5. Response time –
Thus another criteria is the time taken from submission of the
In the "First come first serve" scheduling algorithm, as the name suggests,
the process which arrives first, gets executed first, or we can say that the
process which requests theCPU first, gets the CPU allocated first.
First Come First Serve, is just like FIFO(First in First out) Queue
data structure, where thedata element which is added to the queue
first, is the one who leaves the queue first. This is used in Batch
Systems.
It's easy to understand and implement programmatically, using a
Queue data structure, where a new process enters through the tail of
the queue, and the scheduler selects process from the head of the
queue.
A perfect real life example of FCFS scheduling is buying tickets at
ticket counter. Consider the processes P1, P2, P3, P4 given in the
below table, arrives for execution in the same order, with Arrival
Time 0, and given Burst Time, let's find the average waitingtime
using the FCFS scheduling algorithm.
(21 + 3) ms = 24 ms.
For process P4 it will be the sum of execution times of P1, P2 and P3.
As you can see in the GANTT chart above, the process P4 will be picked up
first as it has the shortest burst time, then P2, followed by P3 and at last P1.
We scheduled the same set of processes using the First come first serve
algorithm in the previous tutorial, and got average waiting time to be 18.75
ms, whereas with SJF, the averagewaiting time comes out 4.5 ms.
the scheduling is done on the basis of priority of the process where the process
which is most urgent is processed first, followed by the ones with lesser
priority in order.
Processes with same priority are executed in FCFS manner.
Consider the below table for processes with their respective CPU burst times and the
priorities.
1. System Processes
2. Interactive Processes
3. Interactive Editing Processes
4. Batch Processes
5. Student Processes
Each queue has absolute priority over lower-priority queues. No
process in the batch queue, for example, could run unless the queues
for system processes, interactive processes, and interactive editing
processes were all empty. If an interactive editing process entered the
ready queue while a batch process was running, the batch processwill
be preempted.