E Content - Os
E Content - Os
UNIT - I
• It provides the base for application program and acts as an intermediary between
a user and the computer hardware.
• The operating system is very important part of almost every computer system.
Page 1 of 22
SE25B
View of operating system
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
Hardware upgrades
New services
Fixes the issues of resources
Controls the user and hardware operations
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
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.
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.
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 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.
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.
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.
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:
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.
• 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.
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:
• 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:
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.
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).
• 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.
SYSTEM PROGRAMS:
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.
• 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.
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:
where as,
• 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:
• Process state: The state may be new, ready, running, waiting or terminated state.
• CPU registers: The registers vary in number & type depending on the computer
architecture.
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 deals with the problem of deciding which of the processes in the
ready queue is to be allocated first to the CPU.
Process Synchronization:
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.
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:
Page 21 of 22
SE25B
Monitor monitor_name
........
........}
........}
Initialization Code
}
Page 22 of 22
SE25B