Operating System Short Notes
Operating System Short Notes
Coffman deadlock refers stamps are older processes, while larger parameters. This is in contrast to
to a specific condition when two or more timestamps represent younger processes. "online" or interactive
processes are each waiting for each other to programs which prompt the user for
release a resource, or more than two processes Scheduling is a key concept in computer such input. A program takes a set of
multitasking, multiprocessing operating data files as input, processes the
are waiting for resources in a circular data, and produces a set of output
system and real-time operating
chain (see Necessary conditions). Deadlock is a data files. This operating
systemdesigns. Scheduling refers to the
common problem in multiprocessing where many way processes are assigned to run on the environment is termed as "batch
processes share a specific type of mutually available CPUs, since there are typically many processing" because the input data
exclusive resource known as a software more processes running than there are are collected into batches on files
lock or soft lock. Computers intended for available CPUs. This assignment is carried out by and are processed in batches by
softwares known as a schedulerand dispatcher. the program.
the time-sharing and/orreal-time markets are
Batch processing has these benefits:
often equipped with a hardware lock (or hard It allows sharing of computer
The scheduler is concerned mainly with:
lock) which guaranteesexclusive access to resources among many users and
processes, forcing serialized access. Deadlocks CPU utilization - to keep the CPU as busy as programs,
are particularly troubling because there is possible. It shifts the time of job processing to
no general solution to avoid (soft) deadlocks. when the computing resources are less
Throughput - number of processes that complete busy,
their execution per time unit. It avoids idling the computing
Necessary conditions Turnaround - total time between submission of a resources with minute-by-minute manual
There are four necessary and sufficient process and its completion intervention and supervision,
conditions for a Coffman deadlock to occur, Waiting time - amount of time a process has been By keeping high overall rate of
known as the Coffman conditions from their first waiting in the ready queue. utilization, it better amortizes the cost of a
description in a 1971 article by E. G. Coffman. computer, especially an expensive one.
Response time - amount of time it takes from
Mutual exclusion condition: a resource that
when a request was submitted until the first A real-time operating
cannot be used by more than one process at a system (RTOS) is an operating system (OS)
response is produced.
time intended for real-time applications. Such
Fairness - Equal CPU time to each
thread. operating systems serve application requests
Hold and wait condition: processes already
nearly real-time. A real-time operating system
holding resources may request new resources In real-time environments, such as mobile
offers programmers more control over process
No preemption condition: No resource can be devices for automatic control in industry (for
priorities. An application's process priority level
forcibly removed from a process holding it, example robotics), the scheduler also must
may exceed that of a system process. Real-time
resources can be released only by the explicit ensure that processes can meet deadlines; this is
operating systems minimize critical sections of
action of the process crucial for keeping the system stable. Scheduled
system code, so that the application's interruption
Circular wait condition: two or more processes tasks are sent to mobile devices
is nearly critical.
form a circular chain where each process waits and managed through an administrative back
for a resource that the next process in the chain end. A key characteristic of a real-time OS is the level
holds of its consistency concerning the amount of time
Prevention Scheduling algorithm it takes to accept and complete an application's
task; the variability is jitter. A hard real-time
In computer science, a scheduling algorithm is operating system has less jitter than a soft real-
Removing the mutual the method by which threads, processes or time operating system. The chief design goal is
exclusion condition means that no process data flows are given access to system resources not high throughput, but rather a guarantee of
may have exclusive access to a resource. (e.g. processor time, communications a soft or hard performance category. A real-time
This proves impossible for resources that bandwidth). This is usually done to load OS that can usually or generally meet
cannot be spooled, and even with spooled balance a system effectively or achieve a a deadline is a soft real-time OS, but if it can
resources deadlock could still occur. target quality of service. The need for a meet a deadlinedeterministically it is a hard real-
Algorithms that avoid mutual exclusion are scheduling algorithm arises from the requirement time OS.
called non-blocking for most modern systems to
synchronization algorithms.
The "hold and wait" conditions may
perform multitasking (execute more than one
process at a time) and multiplexing (transmit
An operating
be removed by requiring processes to multiple flows simultaneously). system (OS) is software, consisting
request all the resources they will need of programs and data, that runs on computers
before starting up (or before embarking and manages the computer hardware and
upon a particular set of operations); this
advance knowledge is frequently difficult to Round-robin (RR) is one of the provides common services for efficient execution
simplest scheduling algorithms for processes in of various application software.
satisfy and, in any case, is an inefficient an operating system, which assigns time slices to each
use of resources. Another way is to require process in equal portions and in circular order, handling all For hardware functions such as input and output
processes to release all their resources processes without priority. Round-robin scheduling is both and memory allocation, the operating system acts
before requesting all the resources they simple and easy to implement, and starvation-free. Round- as an intermediary between application programs
will need. This too is often impractical. robin scheduling can also be applied to other scheduling
problems, such as data packet scheduling in computer and the computer hardware, [1][2] although the
(Such algorithms, such asserializing networks. application code is usually executed directly by
tokens, are known as the all-or-none the hardware, but will frequently call the OS or be
algorithms.) The name of the algorithm comes from the round- interrupted by it. Operating systems are found on
Avoidance robin principle known from other fields, where each person almost any device that contains a computer—
takes an equal share of something in turn.
from cellular phones and video game
Deadlock can be avoided if certain information consoles to supercomputers and web servers.
about processes is available in advance of RR scheduling involves extensive
resource allocation. For every resource request, overhead, especially with a small time unit.
the system sees if granting the request will mean Balanced throughput between
that the system will enter an unsafe state, FCFS and SJF, shorter jobs are completed memory management
meaning a state that could result in deadlock. faster than in FCFS and longer processes
The system then only grants requests that will are completed faster than in SJF. a multiprogramming operating system kernel must be
Fastest average response time, responsible for managing all system memory which is
lead to safe states. In order for the system to be currently in use by programs. This ensures that a program
able to figure out whether the next state will be waiting time is dependent on number of does not interfere with memory already used by another
safe or unsafe, it must know in advance at any processes, and not average process program. Since programs time share, each program must
time the number and type of all resources in length. have independent access to memory.
existence, available, and requested. One known Because of high waiting times,
deadlines are rarely met in a pure RR Cooperative memory management, used by many early
algorithm that is used for deadlock avoidance is operating systems assumes that all programs make
theBanker's algorithm, which requires resource system. voluntary use of the kernel's memory manager, and do not
usage limit to be known in advance. However, for
many systems it is impossible to know in advance
Batch exceed their allocated memory. This system of memory
management is almost never seen anymore, since
what every process will request. This means that processing is execution
programs often contain bugs which can cause them to
exceed their allocated memory. If a program fails it may
deadlock avoidance is often impossible. of a series of programs ("jobs") on cause memory used by one or more other programs to be
a computer without manual affected or overwritten. Malicious programs, or viruses may
Two other algorithms are Wait/Die and purposefully alter another program's memory or may affect
intervention.
Wound/Wait, each of which uses a symmetry- the operation of the operating system itself. With
Batch jobs are set up so they can cooperative memory management it takes only one
breaking technique. In both these algorithms
be run to completion without misbehaved program to crash the system.
there exists an older process (O) and a younger
manual intervention, so all input
process (Y). Process age can be determined by a Memory protection enables the kernel to limit a process'
data is preselected
timestamp at process creation time. Smaller time access to the computer's memory. Various methods of
throughscripts or command-line
memory protection exist, including memory possible to distinguish between algorithms that are merely A file is a collected of related information defined by
segmentation and paging. All methods require some level waiting for a very unlikely set of circumstances to occur and its creator. Computer can store files on the disk
of hardware support (such as the 80286 MMU) which algorithms that will never finish because of deadlock.
doesn't exist in all computers.
(secondary storage), which provide long term storage.
Deadlock detection techniques include, but is not limited Some examples of storage media are magnetic tape,
to, Model checking. This approach constructs a Finite magnetic disk and optical disk. Each of these media
virtual memory The use of virtual State-model on which it performs a progress analysis and has its own properties like speed, capacity, data
memory addressing (such as paging or segmentation) finds all possible terminal sets in the model. These then transfer rate and access methods.
means that the kernel can choose what memory each each represent a deadlock.
A file systems normally organized into directories to
program may use at any given time, allowing the operating
ease their use. These directories may contain files and
system to use the same memory locations for multiple
tasks.
What is a Process? other directions.
A process is a sequential program in execution. The five main major activities of an operating system
If a program tries to access memory that isn't in its current The components of a process are the following: in regard to file management are
range of accessible memory, but nonetheless has been The object program to be executed 1. The creation and deletion of files.
allocated to it, the kernel will be interrupted in the same
( called the program text in UNIX) 2. The creation and deletion of directions.
way as it would if the program were to exceed its allocated
memory. (See section on memory management.) Under The data on which the program will 3. The support of primitives for
UNIX this kind of interrupt is referred to as a page fault. execute (obtained from a file or manipulating files and directions.
interactively from the process's 4. The mapping of files onto secondary
When the kernel detects a page fault it will generally adjust user) storage.
the virtual memory range of the program which triggered it, 5. The back up of files on stable storage
granting it access to the memory requested. This gives the
Resources required by the program
kernel discretionary power over where a particular ( for example, files containing media.
application's memory is stored, or even whether or not it requisite information) Os services
has actually been allocated yet. The status of the process's Program Execution
execution The purpose of a computer systems is to allow the user
Multi-user is a term that defines an operating Process Management to execute programs. So the operating systems
system or application software that allows concurrent Multiprogramming systems explicitly allow provides an environment where the user can
access by multipleusers of a computer. Time- multiple processes to exist at any given time, conveniently run programs. The user does not have to
sharing systems are multi-user systems. Most batch worry about the memory allocation or multitasking or
processing systems for mainframe computers may also be where only one is using the CPU at any given
considered "multi-user", to avoid leaving the CPU idle while moment, while the remaining processes are anything. These things are taken care of by the
it waits for I/O operations to complete. However, the term performing I/O or are waiting. operating systems.
"multitasking" is more common in this context. The process manager is of the four major parts of Running a program involves the allocating and
the operating system. It implements the process deallocating memory, CPU scheduling in case of
An example is a Unix server where multiple remote users multiprocess. These functions cannot be given to the
have access (such as via Secure Shell) to the Unix
abstraction. It does this by creating a model for
shell prompt at the same time. Another example uses the way the process uses CPU and any system user-level programs. So user-level programs cannot
multiple X Window sessions spread across multiple resources. Much of the complexity of the help the user to run programs independently without
terminals powered by a single machine - this is an example operating system stems from the need for the help from operating systems.
of the use of thin client. multiple processes to share the hardware at the
same time. As a conseuence of this goal, the
Multitasking refers to the running of process manager implements CPU sharing
( called scheduling ),
I/O Operations
Each program requires an input and produces output.
multiple independent computer programs on the
process synchronization mechanisms, and a This involves the use of I/O. The operating systems
same computer; giving the appearance that it is
deadlock strategy. In addition, the process hides the user the details of underlying hardware for
performing the tasks at the same time. Since
manager implements part of the operating the I/O. All the user sees is that the I/O has been
most computers can do at most one or two things
system's protection and security. performed without any details. So the operating
at one time, this is generally done via time-
systems by providing I/O makes it convenient for the
sharing, which means that each program uses a Process Management users to run programs.
share of the computer's time to execute.
The operating system manages many kinds of For efficiently and protection users cannot control I/O
An operating system kernel contains a piece of activities ranging from user programs to so this service cannot be provided by user-level
programs.
software called a scheduler which determines system programs like printer spooler, name
how much time each program will spend
servers, file server etc. Each of these activities
executing, and in which order execution control is encapsulated in a process. A process
should be passed to programs. Control is passed File System Manipulation
to a process by the kernel, which allows the includes the complete execution context (code, The output of a program may need to be written into
program access to the CPU and memory. Later, data, PC, registers, OS resources in use etc.). new files or input taken from some files. The
control is returned to the kernel through some It is important to note that a process is not a operating systems provides this service. The user does
not have to worry about secondary storage
mechanism, so that another program may be program. A process is only ONE instant of a
allowed to use the CPU. This so-called passing of management. User gives a command for reading or
program in execution. There are many writing to a file and sees his her task accomplished.
control between the kernel and applications is processes can be running the same program.
called a context switch. Thus operating systems makes it easier for user
The five major activities of an operating programs to accomplished their task.
NTFS (New Technology File System)[1] is the system in regard to process management are This service involves secondary storage management.
standard file system ofWindows NT, including its Creation and deletion of user and The speed of I/O that depends on secondary storage
later versions Windows 2000, Windows management is critical to the speed of many programs
system processes. and hence I think it is best relegated to the operating
XP,Windows Server 2003, Windows Server
2008, Windows Vista, and Windows 7.[5]
Suspension and resumption of systems to manage it than giving individual users the
processes. control of it. It is not difficult for the user-level
NTFS supersedes the FAT file system as the A mechanism for process programs to provide these services but for above
preferred file system for synchronization. mentioned reasons it is best if this service s left with
Microsoft’s Windows operating systems. NTFS operating system.
A mechanism for process
has several improvements over FAT and HPFS
(High Performance File System) such as communication.
improved support for metadata and the use of A mechanism for deadlock Communications
advanced data structures to improve handling. There are instances where processes need to
performance, reliability, and disk space utilization, Main-Memory Management communicate with each other to exchange
plus additional extensions such as information. It may be between processes running on
Primary-Memory or Main-Memory is a large the same computer or running on the different
security access control lists (ACL) and file system
journaling. array of words or bytes. Each word or byte has computers. By providing this service the operating
its own address. Main-memory provides system relieves the user of the worry of passing
Detection storage that can be access directly by the CPU. messages between processes. In case where the
That is to say for a program to be executed, it messages need to be passed to processes on the other
Often, neither avoidance nor deadlock prevention may be must in the main memory. computers through a network it can be done by the
used. Instead deadlock detection and process restart are user programs. The user program may be customized
used by employing an algorithm that tracks resource The major activities of an operating in regard to the specifics of the hardware through which the
allocation and process states, and rolls back and restarts to memory-management are: message transits and provides the service interface to
one or more of the processes in order to remove the
deadlock. Detecting a deadlock that has already occurred Keep track of which part of the operating system.
is easily possible since the resources that each process memory are currently being used
has locked and/or currently requested are known to the
and by whom.
resource scheduler or OS. Error Detection
Decide which process are loaded An error is one part of the system may cause
Detecting the possibility of a deadlock before it occurs is into memory when memory space malfunctioning of the complete system. To avoid such
much more difficult and is, in fact, generally undecidable,
because the halting problem can be rephrased as a becomes available. a situation the operating system constantly monitors
deadlock scenario. However, in specific environments, Allocate and deallocate memory the system for detecting the errors. This relieves the
using specific means of locking resources, deadlock user of the worry of errors propagating to various part
detection may be decidable. In the general case, it is not space as needed.
file Management of the system and causing malfunctioning.
This service cannot allowed to be handled by user etc. but there are also some goals that are
programs because it involves monitoring and in cases desirable in all systems.
altering area of memory or deallocation of memory for
a faulty process. Or may be relinquishing the CPU of a
process that goes into an infinite loop. These tasks are
too critical to be handed over to the user programs. A
user program if given these privileges can interfere
with the correct (normal) operation of the operating
systems.
Layered Approach
DesignIn this case the system is
easier to debug and modify, because
changes affect only limited portions of
the code, and programmer does not have
to know the details of the other layers.
Information is also kept only where it is
needed and is accessible only in certain
ways, so bugs affecting that data are
limited to a specific module or layer.
Threads
.CPU/Process Scheduling
Goals of Scheduling (objectives)
In this section we try to answer following
question: What the scheduler try to achieve?
Many objectives must be considered in the
design of a scheduling discipline. In particular,
a scheduler should consider fairness,
efficiency, response time, turnaround time,
throughput, etc., Some of these goals depends
on the system one is using for example batch
system, interactive system or real-time system,