Академический Документы
Профессиональный Документы
Культура Документы
“ OPERATING SYSTEM”
By
Prof. Anand N. Gharu
(Assistant Professor)
PVGCOE Computer Dept.
05 FEB 20181
.
CONTENTS :-
1. Introduction to different types of OS
2. Real time OS, System Component
3. OS Services, System Structure layer approach
4. Process management: Process concept-state
5. PCB, Thread
6. Process scheduling : preemptive & Non-preemptive
algorithms: FCFS, SJF, RR, Priority
7. Deadlock : Methods of handling deadlock, deadlock
prevention, avoidance, detection & recovery.
8. Case study : Process management in multicore OS
Prof. Gharu Anand N. 2
What’s operating system?
• An Operating System (OS) is an interface between a computer user and
computer hardware. An operating system is a software which performs all
the basic tasks like file management, memory management, process
management, handling input and output, and controlling peripheral devices
such as disk drives and printers.
• I/O operations
• Communication
• Error Detection
• Resource Allocation
• Protection
Prof. Gharu Anand N. 5
• Program execution
• Operating systems handle many kinds of activities from user programs to
system programs like printer spooler, name servers, file server, etc. Each
of these activities is encapsulated as a process.
• A process includes the complete execution context (code to execute, data
to manipulate, registers, OS resources in use). Following are the major
activities of an operating system with respect to program management −
• Loads a program into memory.
• Executes the program.
• Handles program's execution.
• Provides a mechanism for process synchronization.
• Provides a mechanism for process communication.
• Provides a mechanism for deadlock handling.
Prof. Gharu Anand N. 6
• I/O Operation
• An I/O subsystem comprises of I/O devices and their
corresponding driver software. Drivers hide the peculiarities
of specific hardware devices from the users.
• An Operating System manages the communication between
user and device drivers.
• I/O operation means read or write operation with any file or
any specific I/O device.
• Operating system provides the access to the required I/O
device when required.
Prof. Gharu Anand N. 7
• File system manipulation
• A file represents a collection of related information. Computers can
store files on the disk (secondary storage), for long-term storage
purpose. Examples of storage media include magnetic tape, magnetic
disk and optical disk drives like CD, DVD. Each of these media has its
own properties like speed, capacity, data transfer rate and data access
methods.
• Following are the major activities of an operating system with respect
to file management −
• Program needs to read a file or write a file.
• The operating system gives the permission to the program for
operation on file.
• Permission varies from read-only, read-write, denied and so on.
• Operating System provides an interface to the user to create/delete
files.
• Operating System provides an interface to the user to create/delete
directories.
• Operating
Prof. Gharu Anand N.
System provides an interface to create the backup of file 8
• Communication
• In case of distributed systems which are a collection of processors that
do not share memory, peripheral devices, or a clock, the operating
system manages communications between all the processes. Multiple
processes communicate with one another through communication lines
in the network.
• CPU scheduling
Prof. Gharu Anand N. algorithms are used for better utilization of CPU. 10
• Protection
• Considering a computer system having multiple users and concurrent
execution of multiple processes, the various processes must be
protected from each other's activities.
• The OS ensures that external I/O devices are protected from invalid
access attempts.
- Main memory provides a fast storage that can be accessed directly by the CPU. For
a program to be executed, it must in the main memory. An Operating System does
the following activities for memory management −
- Keeps tracks of primary memory, i.e., what part of it are in use by whom, what part
are not in use.
- In multiprogramming, the OS decides which process will get memory when and
how much.
- De-allocates processor
Prof. Gharu Anand N.
when a process is no longer required. 14
Device management
An Operating System manages device communication via their
respective drivers.
- Decides which process gets the device when and for how much
time.
- De-allocates devices.
Prof. Gharu Anand N. 15
File management
A file system is normally organized into directories for easy
navigation and usage. These directories may contain files and other
directions.
CPU is often idle, because the speed of the mechanical I/O devices
is slower than the CPU.
Difficult toAnand
Prof. Gharu provide
N. the desired priority. 20
Multitasking
This set of jobs is a subset of the jobs kept in the job pool.
The operating system picks and begins to execute one of the jobs in the
memory.
Handles I/O device data spooling as devices have different data access rates.
Maintains the spooling buffer which provides a waiting station where data
can rest while the slower device catches up.
CreateProcess() ExitProcess()
Process Control fork() exit() wait()
WaitForSingleObject()
CreateFile() ReadFile()
File Manipulation open() read() write() close()
WriteFile() CloseHandle()
SetConsoleMode() ReadConsole()
Device Manipulation ioctl() read() write()
WriteConsole()
GetCurrentProcessID()
Information Maintenance getpid() alarm() sleep()
SetTimer() Sleeo()
CreatePipe() CreateFileMapping()
Communication pipe() shmget() mmap()
MapViewOfFile()
SetFileSecurity()
Protection InitlializeSecurityDescriptor() chmod() umask() chown()
Prof. Gharu Anand N. SetSecurityDescriptorGroup() 36
Operating system structure
The heart of the system known as virtual machine monitor that runs on
the bare hardware and does the multiprogramming, providing several
virtual machines to next layer up as shown in the given figure.
These virtual machines aren't extended machines, with files and other
nice features. They are the exact copies of the bare hardware, including
the kernel/user mode, Input/Output, interrupts, and everything else the
real Prof. Gharu Anand N.
machine has 44
Microkernel structure
communications facility.
•Communication between components of the OS is provided by message
passing.
The benefits of the microkernel are as follows:
•Extending the operating system becomes much easier.
•Any changes to the kernel tend to be fewer, since the kernel is smaller.
•The microkernel also provides more security and reliability.
Main disadvantage is poor performance due to increased system overhead
Prof. Gharu Anand N. 46
from message passing
Client server structure
By splitting the operating system (OS) up into parts, each of which only
handles one fact of the system, such as file service, terminal service,
process service, or memory service, each part becomes small and
manageable.
MANAGEMENT
CONCEPTS
Prof. Gharu Anand N. 49
Process
User Threads
Kernel Threads
User threads, are above the kernel and without kernel support. These are
the threads that application programmers use in their programs.
Kernel threads are supported within the kernel of the OS itself. All modern
OSs support kernel level threads, allowing the kernel to perform multiple
simultaneous tasks and/or to service multiple kernel system calls
simultaneously.
.
Prof. Gharu Anand N. 60
PROCESS
SCHEDULLING
1. Preemptive process:
In preemptive scheduling policy, a low priority process has to be suspend
its execution if high priority process is waiting in the same queue for its
execution.
Priority Scheduling
Time Quantum is 5
Processes with same priority are executed on first come first served
basis.
1. Shared memory
2. Message passing
message passing :.
in this, instead of reading or writing, processes send and receive the
messages.
send and receive functions are implemented in OS.
The two most common kinds of semaphores are counting semaphores and
binary semaphores. Counting semaphore can take non-negative integer
valuesProf.
and Binary
Gharu Anand N. semaphore can take the value 0 & 1. only. 97
Types of Semaphore
Semaphores are a useful tool in the prevention of race conditions; however,
their use is by no means a guarantee that a program is free from these
problems. Semaphores which allow an arbitrary resource count are
called counting semaphores, while semaphores which are restricted to the
values 0 and 1 (or locked/unlocked, unavailable/available) are
called binary semaphores and are used to implement locks.
1. wait()
2. Signal()
Access When any process access the When any process wants to
shared resources it perform wait() access the shared variables in
operation on S and when it the monitor, it needs to
releases the shared resources it access it through the
performs signal() operation on S. procedures.
Eliminate No Preemption
Preempt resources from process when resources required by other high priority process.
Consider there are n account holders in a bank and the sum of the money in
all of their accounts is S. Everytime a loan has to be granted by the bank, it
subtracts the loan amount from the total money the bank has. Then it
checks if that difference is greater than S. It is done because, only then, the
bank would have enough money even if all the n account holders draw all
their money at once.
Banker's algorithm works in a similar way in computers. Whenever a new
Prof. Gharu Anand N. 115
process is created, it must exactly specify the maximum instances of each
Deadlock Avoidance
Let us assume that there are n processes and m resource types. Some data structures
are used to implement the banker's algorithm. They are:
Need[i][j] = Max[i][j]
Prof. Gharu Anand N. - Allocation [i][j] 116
Bankers Algorithms