Os Unit - 1
Os Unit - 1
• Operating system
• Controls and coordinates use of hardware among various applications and users
• Application programs – define the ways in which the system resources are used to solve
the computing problems of the users
• Users
• People, machines, other computers
1. Efficiency
2. User-friendly
4. Communication
6. Convenience
7. Ease of Evolution
To act as an intermediary between the hardware and its users, making it easier for the users to
access and use other resources.
To keep track of who is using which resource, granting resource requests, and mediating
conflicting requests from different programs and users.
To provide efficient and fair sharing of resources among users and programs.
1. Memory Management
2. Processor Management
3. Device Management
4. File Management
5. Security
7. Error detecting
Memory Management –
The operating system manages Primary Memory or Main Memory. Main memory is made up of a large
array of bytes or words where each byte or word is assigned a certain address. Main memory is fast
storage, and it can be accessed directly by the CPU. For a program to be executed, it should be first
loaded in the main memory. An Operating System performs the following activities for memory
management:
It keeps track of primary memory, i.e., which bytes of memory are used by which user program. The
memory addresses that have already been allocated and the memory addresses of the memory that has
not yet been used. In multiprogramming, the OS decides the order in which processes are granted
access to memory, and for how long. It Allocates the memory to a process when the process requests it
and deallocates the memory when the process has terminated or is performing an I/O operation.
Processor Management –
In a multi-programming environment, the OS decides the order in which processes have access to the
processor, and how much processing time each process has. This function of OS is called process
scheduling. An Operating System performs the following activities for processor management.
Keeps track of the status of processes. The program which performs this task is known as a traffic
controller. Allocates the CPU that is a processor to a process. De-allocates processor when a process is
no more required.
Device Management –
An OS manages device communication via their respective drivers. It performs the following activities for
device management. Keeps track of all devices connected to the system. designates a program
responsible for every device known as the Input/Output controller. Decides which process gets access to
a certain device and for how long. Allocates devices in an effective and efficient way. Deallocates devices
when they are no longer required.
File Management –
A file system is organized into directories for efficient or easy navigation and usage. These directories
may contain other directories and other files. An Operating System carries out the following file
management activities. It keeps track of where information is stored, user access settings and status of
every file, and more… These facilities are collectively known as the file system.
Security –
The operating system uses password protection to protect user data and similar other techniques. it also
prevents unauthorized access to programs and user data.
Monitors overall system health to help improve performance. records the response time between
service requests and system response to having a complete view of the system health. This can help
improve performance by providing important information needed to troubleshoot problems.
Operating systems also coordinate and assign interpreters, compilers, assemblers, and other software to
the various users of the computer systems.
An operating system provides an environment for the execution of programs. It provides certain services
to programs and to the users of those programs. The specific services provided, of course, differ from
one operating system to another, but we can identify common classes. These operating system services
are provided for the convenience of the programmer, to make the programming task easier.
User interface : Almost all operating systems have a user interface (UI). This interface can take several
forms. One is a command-line interface (CLI), which uses text commands and a method for entering
them (say, a program to allow entering and editing of commands). Another is a batch interface, in which
commands and directives to control those commands are entered into files, and those files are
executed. Most commonly, a graphical user interface (GUI) is used. Here, the interface is a window
system with a pointing device to direct I/O, choose from menus, and make selections and a keyboard to
enter text. Some systems provide two or all three of these variations.
Program execution : The system must be able to load a program into memory and to run that program.
The program must be able to end its execution, either normally or abnormally (indicating error).
I/O operations. A running program may require I/O, which may involve a file or an I/O device. For
specific devices, special functions may be desired (such as recording to a CD or DVD drive or blanking a
CRT screen). For efficiency and protection, users usually cannot control I/O devices directly. Therefore,
the operating system must provide a means to do I/O.
File-system manipulation : The file system is of particular interest. Obviously, programs need to read
and write files and directories. They also need to create and delete them by name, search for a given
file, and list file information. Finally, some programs include permissions management to allow or deny
access to files or directories based on file ownership. The operating system is responsible for granting
these permissions to application programs.
Communications : There are many circumstances in which one process needs to exchange information
with another process. Such communication may occur between processes that are executing on the
same computer or between processes that are executing on different computer systems tied together
by a computer network. Communications may be implemented via shared memory or through message
passing, in which packets of information are moved between processes by the operating system.
Error detection. The operating system needs to be constantly aware of possible errors. Errors may occur
in the CPU and memory hardware (such as a memory error or a power failure), in I/O devices (such as a
parity error on tape, a connection failure on a network, or lack of paper in the printer), and in the user
program (such as an arithmetic overflow, an attempt to access an illegal memory location, or a too-great
use of CPU time). For each type of error, the operating system should take the appropriate action to
ensure correct and consistent computing. Debugging facilities can greatly enhance the user's and
programmer's abilities to use the system efficient.
Resource allocation : When there are multiple users or multiple jobs running at the same time,
resources must be allocated to each of them. We can view an operating system as a resource allocator.
OS keeps track of the status of each resource and decides who gets a resource, for how long, and when
OS makes sure that different programs and users are running at the same time but do not interfere with
each other.
Accounting : We want to keep track of which users use how much and what kinds of computer
resources. This record keeping may be used for accounting (so that users can be billed) or simply for
accumulating usage statistics. Usage statistics may be a valuable tool for researchers who wish to
reconfigure the system to improve computing services.
Protection and security : It involve ensuring that all access to system resources is controlled . Security of
the system from outsiders requires user authentication, extends to defending external I/O devices from
invalid access attempts.
SYSTEM CALLS
When a program in user mode requires access to RAM or a hardware resource, it must ask the kernel to
provide access to that resource. This is done via something called a system call.
When a program makes a system call, the mode is switched from user mode to kernel mode. This is
called a context switch.
There are 5 different categories of system calls:
• Process Control: A running program needs to be able to stop execution either normally or
abnormally. When execution is stopped abnormally, often a dump of memory is taken and can
be examined with a debugger.
• File Manipulation: Some common system calls are created, delete, read, write, reposition, or
close. Also, there is a need to determine the file attributes – get and set file attributes. Many
times, the OS provides an API to make these system calls.
• Device Manipulation: Process usually requires several resources to execute, if these resources
are available, they will be granted, and control returned to the user process. These resources
are also thought of as devices. Some are physical, such as a video card, and others are abstract,
such as a file. User programs request the device, and when finished they release the device. Like
files, we can read, write, and reposition the device.
• Information maintenance :Some system calls exist purely for transferring information between
the user program and the operating system. An example of this is time, or date. The OS also
keeps information about all its processes and provides system calls to report this information.
• Communication: There are two models of inter process communication, the message-passing
model, and the shared memory model. Message-passing uses a common mailbox to pass
messages between processes. Shared memory use certain system calls to create and gain access
to regions of memory owned by other processes. The two processes exchange information by
reading and writing in the shared data.
SCHEDULING CRITERIA
Different CPU scheduling algorithms have different properties, and the choice of a particular
algorithm may favor one class of processes over another. In choosing which algorithm to use in a
particular situation, we must consider the properties of the various algorithms.
Many criteria have been suggested for comparing CPU scheduling algorithms. Which
characteristics are used for comparison can make a substantial difference in which algorithm is
judged to be best? The criteria include the following:
• CPU utilization. We want to keep the CPU as busy as possible. Conceptually, CPU utilization
can range from 0 to 100 percent. In a real system, it should range from 40 percent (for a lightly
loaded system) to 90 percent(for a heavily used system).
• Throughput. If the CPU is busy executing processes, then work is being done. One measure of
work is the number of processes that are completed per time unit, called throughput. For long
processes, this rate may be one process per hour; for short transactions, it may be 10 processes
per second.
• Turnaround time. From the point of view of a particular process, the important criterion is
how long it takes to execute that process. The interval from the time of submission of a process
to the time of completion is the turnaround time. Turnaround time is the sum of the periods
spent waiting to get into memory, waiting in the ready queue, executing on the CPU, and doing
I/O.
• Waiting time. The CPU scheduling algorithm does not affect the amount of time during which
a process executes or does I/O; it affects only theamount of time that a process spends waiting
in the ready queue. Waiting time is the sum of the periods spent waiting in the ready queue.
• Response time. In an interactive system, turnaround time may not be the best criterion.
Often, a process can produce some output early and can continue computing new results while
previous results are being output to the user. Thus, another measure is the time from the
submission of a request until the first response is produced. This measure, called response time,
is the time it takes to start responding, not the time it takes to output the response. The
turnaround time is generally limited by the speed of the output device