0% found this document useful (0 votes)
21 views22 pages

E Content - Os

Uploaded by

deborahravi275
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views22 pages

E Content - Os

Uploaded by

deborahravi275
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 22

DEPARTMENT OF COMPUTER APPLICATION

SUBJECT: OPERATING SYSTEM

SUB CODE: SE25B

UNIT - I

Operating System Definition:

• An operating system is a program which manages all the computer’s hardware.

• It provides the base for application program and acts as an intermediary between
a user and the computer hardware.

• The operating system has two objectives such as:

 Firstly, an operating system controls the computer’s hardware.


 The second objective is to provide an interactive interface to the user and
interpret commands so that it can communicate with the hardware.

• The operating system is very important part of almost every computer system.

Page 1 of 22
SE25B
View of operating system

 User View of Operating System:

The Operating System is an interface, hides the details which must be


performed and present a virtual machine to the user that makes it easier to use.
Operating System provides the following services to the user.

 Execution of a program
 Access to I/O devices
 Controlled access to files
 Error detection (Hardware failures, and software errors)
Types of User View Points are as follows:
 Single user view point
 Multiple user view point
 Handled user view point
 Embedded System user view Point

 System View of Operating System:

Operating System is a program that functions in the same way as other


programs. It is a set of instructions that are executed by the processor.
Operating System acts as a program to perform the following.

 Hardware upgrades
 New services
 Fixes the issues of resources
 Controls the user and hardware operations

Types of System View Points are as follows:


 Resource Allocation
 Control program

Types of Operating Systems


There are several types of Operating Systems which are mentioned below.
 Batch Operating System

Page 2 of 22
SE25B
 Multi-Programming System
 Multi-Processing System
 Multi-Tasking Operating System
 Time-Sharing OS
 Distributed Operating System
 Network OS
 Real-Time OS

1. Batch Operating System


This type of operating system does not interact with the computer directly. There
is an operator which takes similar jobs having the same requirement and groups
them into batches. It is the responsibility of the operator to sort jobs with similar
needs.

Batch Operating System

Advantages of Batch Operating System


 Multiple users can share the batch systems.
 The idle time for the batch system is very less.
 It is easy to manage large work repeatedly in batch systems.

Disadvantages of Batch Operating System


 The computer operators should be well known with batch systems.
 Batch systems are hard to debug.
 It is sometimes costly.
 The other jobs will have to wait for an unknown time if any job fails.
 In batch operating system the processing time for jobs is commonly difficult
to accurately predict while they are in the queue.

 It is difficult to accurately predict the exact time required for a job to complete
while it is in the queue.

Page 3 of 22
SE25B
Examples of Batch Operating Systems:
Payroll Systems, Bank Statements, etc.

2. Multi-Programming Operating System


Multi-Programming System can be simply illustrated as more than one
program is present in the main memory and any one of them can be kept in
execution. This is basically used for better execution of resources.

Advantages of Multi-Programming Operating System


 Multi Programming increases the Throughput of the System.
 It helps in reducing the response time.

Disadvantages of Multi-Programming Operating System


 There is not any facility for user interaction of system resources with the
system.

3. Multi-Processing Operating System


Multi-Processing System is a type of Operating System in which more than
one CPU is used for the execution of resources. It betters the throughput of the
System.

Page 4 of 22
SE25B
Advantages of Multi-Processing Operating System
 It increases the throughput of the system.
 As it has several processors, so, if one processor fails, we can proceed with
another processor.

Disadvantages of Multi-Processing Operating System


 Due to the multiple CPU, it can be more complex and somehow difficult to
understand.

4. Time-Sharing Operating Systems

Each task is given some time to execute so that all the tasks work smoothly. Each
user gets the time of the 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.

Page 5 of 22
SE25B
5. Distributed Operating System

These types of operating system is a recent advancement in the world of


computer technology and are being widely accepted all over the world and, that
too, at a great pace. 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 systems’ 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.

Basic Functions of Operation System:

The various functions of operating system are as follows:

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.

Page 6 of 22
SE25B
• These resources are either given to the process when it is created or
allocated to it while it is running. The OS is responsible for the
following activities of process management.
• Creating & deleting both user & system processes.
• Suspending & resuming processes.
• Providing mechanism for process synchronization.
• Providing mechanism for process communication.
• Providing mechanism for deadlock handling.

2. Main Memory Management:


The main memory is central to the operation of a modern computer
system. Main memory is a large array of words or bytes ranging in
size from hundreds of thousand to billions. Main memory stores the
quickly accessible data shared by the CPU & I/O device. The central
processor reads instruction from main memory during instruction
fetch cycle & it both reads &writes data from main memory during
the data fetch cycle. The main memory is generally the only large
storage device that the CPU is able to address & access directly.

For example,
for the CPU to process data from disk. Those data must first be
transferred to main memory by CPU generated E/O calls.
Instruction must be in memory for the CPU to execute them. The OS
is responsible for the following activities in connection with memory
management.
• Keeping track of which parts of memory are currently being used &
by whom.
• Deciding which processes are to be loaded into memory when
memory space becomes available.
• Allocating &deallocating memory space as needed.

3. File Management:
File management is one of the most important components of an OS
computer can store information on several different types of physical

Page 7 of 22
SE25B
media magnetic tape, magnetic disk & optical disk are the most
common media.
The OS abstracts from the physical properties of its storage devices to
define a logical storage unit the file.
A file is collection of related information defined by its creator. The
OS is responsible for the following activities of file management.

• Creating & deleting files.


• Creating & deleting directories.
• Supporting primitives for manipulating files & directories.
• Mapping files into secondary storage.
• Backing up files on non-volatile media.

4. I/O System Management:


One of the purposes of an OS is to hide the peculiarities of specific
hardware devices from the user.
For example,
in UNIX the peculiarities of I/O devices are hidden from the bulk of
the OS itself by the I/O subsystem.
The I/O subsystem consists of:
• A memory management component that includes buffering,
catching & spooling.
• A general device- driver interfaces drivers for specific hardware
devices. Only the device driver knows the peculiarities of the specific
device to which it is assigned

5. Secondary Storage Management:


The main purpose of computer system is to execute programs. These
programs with the data they access must be in main memory during
execution. As the main memory is too small to accommodate all data
& programs & because the data that it holds are lost when power is
lost. The computer system must provide secondary storage to back-up
main memory. Most modern computer systems are disks as the
storage medium to store data & program.

Page 8 of 22
SE25B
The operating system is responsible for the following activities of disk
management.
• Free space management.
• Storage allocation.
• Disk scheduling Because secondary storage is used frequently it
must be used efficiently.

Networking:

A distributed system is a collection of processors that don’t share memory


peripheral devices or a clock. Each processor has its own local memory & clock
and the processor communicate with one another through various communication
lines such as high speed buses or networks. The processors in the system are
connected through communication networks which are configured in a number of
different ways. The communication network design must consider message routing
& connection strategies are the problems of connection & security.

 Protection or security: If a computer system has multi users &


allow the concurrent execution of multiple processes then the
various processes must be protected from one another’s
activities. For that purpose, mechanisms ensure that files,
memory segments, CPU & other resources can be operated on
by only those processes that have gained proper authorization
from the OS.
 Command interpretation: One of the most important
functions of the OS is connected interpretation where it acts as
the interface between the user & the OS.

Operating Systems Structures

The operating system can be implemented with the help of various structures. The
structure of the OS depends mainly on how the various standard components of
the operating system are interconnected and melded into the kernel.

The following structures in the operating system:


Page 9 of 22
SE25B
1. Simple/Monolithic Structure
2. Micro-Kernel Structure
3. Hybrid-Kernel Structure
4. Exo-Kernel Structure
5. Layered Structure
6. Modular Structure
7. Virtual Machines

Operating System Services

An operating system provides an environment for the execution of the program. It


provides some services to the programs.

The various services provided by an operating system are as follows:

• Program Execution:

The system must be able to load a program into memory and to run that program.
The program must be able to terminate this execution either normally or
abnormally.

• I/O Operation:

A running program may require I/O. This I/O may involve a file or a I/O device
for specific device. Some special function can be desired.

Therefore the operating system must provide a means to do I/O.

• File System Manipulation:

The programs need to create and delete files by name and read and write files.
Therefore the operating system must maintain each and every files correctly.

• Communication:

The communication is implemented via shared memory or by the technique of


message passing in which packets of information are moved between the processes
by the operating system.

• Error detection:

Page 10 of 22
SE25B
The operating system should take the appropriate actions for the occurrences of
any type like arithmetic overflow, access to the illegal memory location and too
large user CPU time.

• Research Allocation:

When multiple users are logged on to the system the resources must be allocated to
each of them. For current distribution of the resource among the various processes
the operating system uses the CPU scheduling run times which determine which
process will be allocated with the resource.

• Accounting:

The operating system keep track of which users use how many and which kind of
computer resources.

• Protection:

The operating system is responsible for both hardware as well as software


protection. The operating system protects the information stored in a multiuser
computer system.

System Calls:

System calls provide the interface between a process & the OS. These are usually
available in the form of assembly language instruction. Some systems allow
system calls to be made directly from a high level language program like C, BCPL
and PERL etc. systems calls occur in different ways depending on the computer in
use.

System calls can be roughly grouped into 5 major categories.

1. Process Control:
• End, abort: A running program needs to be able to has its execution
either normally (end) or abnormally (abort).
• Load, execute: A process or job executing one program may want to
load and executes another program.

Page 11 of 22
SE25B
• Create Process, terminate process: There is a system call specifying
for the purpose of creating a new process or job (create process or
submit job). We may want to terminate a job or process that we
created (terminates process, if we find that it is incorrect or no longer
needed).

• Get process attributes, set process attributes: If we create a new job


or process we should able to control its execution. This control
requires the ability to determine & reset the attributes of a job or
processes (get process attributes, set process attributes).

• Wait time: After creating new jobs or processes, we may need to


wait for them to finish their execution (wait time).

• Wait event, signal event: We may wait for a specific event to occur
(wait event). The jobs or processes then signal when that event has
occurred (signal event).

2. File Manipulation:
• Create file, delete file: We first need to be able to create & delete
files. Both the system calls require the name of the file & some of its
attributes.

• Open file, close file: Once the file is created, we need to open it &
use it. We close the file when we are no longer using it.

• Read, write, reposition file: After opening, we may also read, write
or reposition the file (rewind or skip to the end of the file).

• Get file attributes, set file attributes: For either files or directories,
we need to be able to determine the values of various attributes &
reset them if necessary. Two system calls get file attribute & set file
attributes are required for their purpose.

3. Device Management:

Page 12 of 22
SE25B
• Request device, release device: If there are multiple users of the
system, we first request the device. After we finished with the device,
we must release it.

• Read, write, reposition: Once the device has been requested &
allocated to us, we can read, write & reposition the device.

4 Information maintenance:
• Get time or date, set time or date: Most systems have a system call
to return the current date & time or set the current date & time.

• Get system data, set system data: Other system calls may return
information about the system like number of current users, version
number of OS, amount of free memory etc.

• Get process attributes, set process attributes: The OS keeps


information about all its processes & there are system calls to access
this information.

6. Communication: There are two modes of communication such as:


• Message passing model:
• Shared memory model

SYSTEM PROGRAMS:

System programs provide a convenient environment for program development &


execution. They are divided into the following categories.

o File manipulation
o Status information
o File modification
o Programming language support
o Programming loading and execution
o Communications
o Application programs

Page 13 of 22
SE25B
System structure:

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. 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 o ) is the hardware & top
most layer (layer N) is the user interface. The main advantage of the layered
approach is modularity.

Operating System Services

An operating system provides an environment for the execution of the program. It


provides some services to the programs.

The various services provided by an operating system are as follows:

• Program Execution
• I/O Operation
• File System Manipulation
• Communication
• Error detection
• Research Allocation

Page 14 of 22
SE25B
• Accounting
• Protection
OS Design and implementation
The design and implementation of an operating system is a complex process that
involves many different disciplines. The goal is to provide users with a reliable,
efficient, and convenient computing environment, so as to make their work more
efficient. There are many problems that can occur while designing and
implementing an operating system. These are covered in operating system design
and implementation.

Operating System Design Goals


It is quite complicated to define all the goals and specifications of the operating
system while designing it. The design changes depending on the type of the
operating system i.e if it is batch system, time shared system, single user system,
multi user system, distributed system etc.
There are basically two types of goals while designing an operating system. These
are −
 User Goals
The operating system should be convenient, easy to use, reliable, safe and fast
according to the users. However, these specifications are not very useful as there is
no set method to achieve these goals.
 System Goals

Page 15 of 22
SE25B
The operating system should be easy to design, implement and maintain. These are
specifications required by those who create, maintain and operate the operating
system. But there is not specific method to achieve these goals as well.
Process Management:

Process: A process or task is an instance of a program in execution. The execution


of a process must programs in a sequential manner. At any time at most one
instruction is executed. The process includes the current activity as represented by
the value of the program counter and the content of the processors registers.

Difference between process & program:

A program by itself is not a process. A program in execution is known as a


process. A program is a passive entity, such as the contents of a file stored on disk

where as,

process is an active entity with a program counter specifying the next


instruction to execute and a set of associated resources may be shared among
several process with some scheduling algorithm being used to determinate when
the stop work on one process and service a different one.

 Process state: As a process executes, it changes state. The state of a process


is defined by the correct activity of that process. Each process may be in one
of the following states.

• New: The process is being created.

• Ready: The process is waiting to be assigned to a processor.

• Running: Instructions are being executed.

• Waiting: The process is waiting for some event to occur.

• Terminated: The process has finished execution. Many processes may be in ready
and waiting state at the same time. But only one process can be running on any
processor at any instant.

Page 16 of 22
SE25B
PROCESS STATE

Process scheduling:

The process scheduling is the activity of the process manager that handles the
removal of the running process from the CPU and the selection of another process
on the basis of a particular strategy.
Process scheduling is an essential part of a Multiprogramming operating systems.
Such operating systems allow more than one process to be loaded into the
executable memory at a time and the loaded process shares the CPU using time
multiplexing.
Process control block:

Each process is represented in the OS by a process control block. It is also by a


process control block. It is also known as task control block.

A process control block contains many pieces of information associated with a


specific process. It includes the following informations.

• Process state: The state may be new, ready, running, waiting or terminated state.

• Program counter: It indicates the address of the next instruction to be executed


for this purpose.

• CPU registers: The registers vary in number & type depending on the computer
architecture.

• Memory management information: This information may include such


information as the value of the bar & limit registers, the page tables or the segment
tables, depending upon the memory system used by the operating system.

Page 17 of 22
SE25B
• Accounting information: This information includes the amount of CPU and real
time used, time limits, account number, job or process numbers and so on.

• I/O Status Information: This information includes the list of I/O devices
allocated to this process, a list of open files and so on. The PCB simply serves as
the repository for any information that may vary from process to process.

CPU Scheduling Algorithm:

CPU Scheduling deals with the problem of deciding which of the processes in the
ready queue is to be allocated first to the CPU.

There are four types of CPU scheduling that exist.

 First Come, First Served Scheduling (FCFS) Algorithm


 Shortest Job First Scheduling (SJF) Algorithm
 Priority Scheduling Algorithm
 Round Robin Scheduling Algorithm

Process Synchronization:

A co-operation process is one that can affect or be affected by other processes


executing in the system. Co-operating process may either directly share a logical
address space or be allotted to the shared data only through files. This concurrent
access is known as Process synchronization.

Critical Section Problem:

The critical section is a code segment where the shared variables can be accessed.
An atomic action is required in a critical section i.e. only one process can execute
in its critical section at a time. All the other processes have to wait to execute in
their critical sections.
A diagram that demonstrates the critical section is as follows −

Page 18 of 22
SE25B
In the above diagram, the entry section handles the entry into the critical section. It
acquires the resources needed for execution by the process. The exit section
handles the exit from the critical section. It releases the resources and also informs
the other processes that the critical section is free.
Solution to the Critical Section Problem
The critical section problem needs a solution to synchronize the different
processes. The solution to the critical section problem must satisfy the following
conditions −
 Mutual Exclusion
Mutual exclusion implies that only one process can be inside the critical
section at any time. If any other processes require the critical section, they
must wait until it is free.
 Progress
Progress means that if a process is not using the critical section, then it
should not stop any other process from accessing it. In other words, any
process can enter a critical section if it is free.
 Bounded Waiting
Bounded waiting means that each process must have a limited waiting time.
Itt should not wait endlessly to access the critical section.
Semaphores are integer variables that are used to solve the critical section problem
by using two atomic operations, wait and signal that are used for process
synchronization.

Page 19 of 22
SE25B
The definitions of wait and signal are as follows −
 Wait
The wait operation decrements the value of its argument S, if it is positive.
If S is negative or zero, then no operation is performed.
wait(S)
{
while (S<=0);

S--;
}
 Signal
The signal operation increments the value of its argument S.
signal(S)
{
S++;
}

Types of Semaphores
There are two main types of semaphores i.e. counting semaphores and binary
semaphores. Details about these are given as follows −
 Counting Semaphores
These are integer value semaphores and have an unrestricted value domain.
These semaphores are used to coordinate the resource access, where the
semaphore count is the number of available resources. If the resources are
added, semaphore count automatically incremented and if the resources are
removed, the count is decremented.

 Binary Semaphores
The binary semaphores are like counting semaphores but their value is
restricted to 0 and 1. The wait operation only works when the semaphore is 1
and the signal operation succeeds when semaphore is 0. It is sometimes
easier to implement binary semaphores than counting semaphores.
Advantages of Semaphores
Some of the advantages of semaphores are as follows −

Page 20 of 22
SE25B
 Semaphores allow only one process into the critical section. They follow the
mutual exclusion principle strictly and are much more efficient than some
other methods of synchronization.
 There is no resource wastage because of busy waiting in semaphores as
processor time is not wasted unnecessarily to check if a condition is fulfilled
to allow a process to access the critical section.
 Semaphores are implemented in the machine independent code of the
microkernel. So they are machine independent.
Disadvantages of Semaphores
Some of the disadvantages of semaphores are as follows −
 Semaphores are complicated so the wait and signal operations must be
implemented in the correct order to prevent deadlocks.
 Semaphores are impractical for last scale use as their use leads to loss of
modularity. This happens because the wait and signal operations prevent the
creation of a structured layout for the system.
 Semaphores may lead to a priority inversion where low priority processes
may access the critical section first and high priority processes later.

Classical Problems of Synchronization with Semaphore Solution

Synchronization Problems

These problems are used for testing nearly every newly proposed
synchronization scheme. The following problems of synchronization are
considered as classical problems:
 Bound-buffer (or producer-consumer)problem,
 Dining-Philosophers problem,
 Readers and Writers Problem,
 Sleeping Barber Problem

Monitors:

It is characterized as a set of programmer defined operators. Its


representation consists of declaring of variables, whose value defines the state of
an instance. The syntax of monitor is as follows.

Page 21 of 22
SE25B
Monitor monitor_name

Shared variable declarations

Procedure body P1 (………) {

........

Procedure body P2 (………) {

........}

Procedure body Pn (………) {

........}

Initialization Code
}

Page 22 of 22
SE25B

You might also like