unit 1 Operating system
unit 1 Operating system
An Operating System (OS) is an interface between computer user and computer hardware. It
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.
Some popular Operating Systems include Linux Operating System, Windows Operating
System, VMS, OS/400, AIX, z/OS, etc.
Definition
An operating system is a program that acts as an interface between the user and the
computer hardware and controls the execution of all kinds of programs.
Operating System as a Resource Manager:
It controls the working of hardware and also the programs that we run. Whenever we
run a program the OS allocates memory and loads the program into it.
Similarly when we request some hardware the OS is the one that raises the request
and makes it available. So it is involved in all control activities in the computer.
Functions of an Operating System
Memory Management
Processor Management
Device Management
File Management
Security
Control over system performance
Job accounting
Error detecting aids
Coordination between other software and users
Memory Management
Memory management refers to management of Primary Memory or Main Memory. Main
memory is a large array of words or bytes where each word or byte has its own address.
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.
Allocates the memory when a process requests it to do so.
De-allocates the memory when a process no longer needs it or has been terminated.
Processor Management
In multiprogramming environment, the OS decides which process gets the processor when
and for how much time. This function is called process scheduling. An Operating System
does the following activities for processor management −
Keeps tracks of processor and status of process. The program responsible for this task
is known as traffic controller.
Allocates the processor (CPU) to a process.
De-allocates processor when a process is no longer required.
Device Management
An Operating System manages device communication via their respective drivers. It does
the following activities for device management −
Keeps tracks of all devices. Program responsible for this task is known as the I/O
controller.
Decides which process gets the device when and for how much time.
Allocates the device in the efficient way.
De-allocates devices.
File Management
A file system is normally organized into directories for easy navigation and usage. These
directories may contain files and other directions.
An Operating System does the following activities for file management −
Keeps track of information, location, uses, status etc. The collective facilities are
often known as file system.
Decides who gets the resources.
Allocates the resources.
De-allocates the resources.
Other Important Activities
Following are some of the important activities that an Operating System performs −
Security − By means of password and similar other techniques, it prevents
unauthorized access to programs and data.
Control over system performance − Recording delays between request for a service
and response from the system.
Job accounting − Keeping track of time and resources used by various jobs and
users.
Error detecting aids − Production of dumps, traces, error messages, and other
debugging and error detecting aids.
Coordination between other softwares and users − Coordination and assignment
of compilers, interpreters, assemblers and other software to the various users of the
computer systems.
Classification of Operating System
An interactive operating system is one that allows the user to directly interact with
the operating system whilst one or more programs are running. There will be an user
interface in place to allow this to happen. It could be a command line style of interface or it
could be a graphical interface.
Example: ATM
Time-sharing operating systems
Each task is given some time to execute, so that all the tasks work smoothly. Each user gets
time of CPU as they use single system. These systems are also known as Multitasking
Systems. The task can be from single user or from different users also. The time that each
task gets to execute is called quantum. After this time interval is over OS switches over to
next task.
In a multitasking system more than one task can be performed at the same time but they are
executed one after another through a single CPU by time sharing. For example: Windows,
Linux, Mac, Unix,etc.
Multitasking OS are of two types:
a) Pre-empetive multitasking
b) Co-operative multitasking
In the pre-empetive multitasking, the OS allows CPU times slice to each program. After each
time slice, CPU executes another task. Example: Windows XP
In co-operative multitasking a task can control CPU as long as it requires . However, it will
free CPU to execute another program if it doesn’t require CPU. Exaample: windows 3.x,
multifinder,etc.
Hard real-time systems guarantee that critical tasks complete on time. In hard real-
time systems, secondary storage is limited or missing and the data is stored in
ROM. In these systems, virtual memory is almost never found.
Soft real-time systems are less restrictive. A critical real-time task gets priority over
other tasks and retains the priority until it completes. Soft real-time systems have
limited utility than hard real-time systems. For example, multimedia, virtual reality,
Advanced Scientific Projects like undersea exploration and planetary rovers, etc.
Advantages of RTOS:
Maximum Consumption: Maximum utilization of devices and system,thus
more output from all the resources
Task Shifting: Time assigned for shifting tasks in these systems are very
less. For example in older systems it takes about 10 micro seconds in shifting
one task to another and in latest systems it takes 3 micro seconds.
Focus on Application: Focus on running applications and less importance to
applications which are in queue.
Real time operating system in embedded system: Since size of programs
are small, RTOS can also be used in embedded systems like in transport and
others.
Error Free: These types of systems are error free.
Memory Allocation: Memory allocation is best managed in these type of
systems.
Disadvantages of RTOS:
Limited Tasks: Very few tasks run at the same time and their concentration
is very less on few applications to avoid errors.
Use heavy system resources: Sometimes the system resources are not so
good and they are expensive as well.
Complex Algorithms: The algorithms are very complex and difficult for the
designer to write on.
Device driver and interrupt signals: It needs specific device drivers and
interrupt signals to response earliest to interrupts.
Thread Priority: It is not good to set thread priority as these systems are very
less prone to switching tasks.
Examples of Real-Time Operating Systems are: Scientific experiments, medical
imaging systems, industrial control systems, weapon systems, robots, air traffic
control systems, etc
Example: Operating system like Unix, 64 bit edition of windows, server edition of
windows, etc. are multiprocessing.
Multiuser operating System
In a multiuser OS, more than one user can use the same system at a same time through the
multi I/O terminal or through the network.
For example: windows, Linux, Mac, etc.
A multiuser OS uses timesharing to support multiple users.
1. Simple structure
2. Monolithic Kernel
5. Reentrant kernel
If the kernel is not re-entrant, a process can only be
suspended while it is in user mode. Although it could be
suspended in kernel mode, that would still block kernel
mode execution on all other processes.
The reason for this is that all kernel threads share the
same memory. If execution would jump between them
arbitrarily, corruption might occur
A re-entrant kernel enables processes (or, to be more
precise, their corresponding kernel threads) to give away
the CPU while in kernel mode. They do not hinder other
processes from also entering kernel mode. If a hardware
interrupt occurs, a reentrant kernel is able to suspend
the current running process even if that process is in
Kernel Mode. This capability is very important, because
it improves the throughput of the device controllers that
issue interrupts
For instance, after issuing a read to a disk on behalf of a
process, the kernel lets the disk controller handle it and
resumes executing other processes. An interrupt notifies
the kernel when the device has satisfied the read, so the
former process can resume the execution.
One way to provide reentrancy is to write functions so
that they modify only local variables and do not alter
global data structures. Such functions are called
reentrant functions. But a reentrant kernel is not limited
only to such reentrant functions (although that is how
some real-time kernels are implemented). Instead, the
kernel can include nonreentrant functions and use
locking mechanisms to ensure that only one process can
execute a nonreentrant function at a time.
.Once a device has issued an interrupt, it waits until the
CPU acknowledges it. If the kernel is able to answer
quickly, the device controller will be able to perform
other tasks while the CPU handles the interrupt.
Operating-System Components
A system as large and complex as a modern operating system must be engineered
carefully if it is to function properly and be modified easily.
A common approach is to partition the task into small components rather than
have one monolithic system.
Each of these modules should be a well-defined portion of the system, with carefully
defined inputs, outputs, and functions.
1. Process Management
2. Memory Management
Main Memory is a large array of storage or bytes, which has an address. The memory
management process is conducted by using a sequence of reads or writes of specific
memory addresses.
In order to execute a program, it should be mapped to absolute addresses and loaded
inside the Memory. The selection of a memory management method depends on
several factors.
Main Memory offers fast storage that can be accessed directly by the CPU. It is costly
and hence has a lower storage capacity. However, for a program to be executed, it
must be in the main Memory.
For example, in UNIX, the peculiarities of I/O devices are hidden from the bulk of
the operating system itself by the I/O system. The I/O system consists of:
A buffer caching system
A general device driver code
Drivers for specific hardware devices.
5. File management
A file is a set of related information which is define by its creator. It commonly
represents programs, both source and object forms, and data.
The operating system implements the abstract concept of the file by managing mass
storage device, such as types and disks.
Also files are normally organized into directories to ease their use. Finally, when
multiple users have access to files, it may be desirable to control by whom and in
what ways files may be accessed.
The operating system has the following important given activities in connections with
file management:
6. Protection system
The various processes in an operating system need to be secured from each other's
activities. For that purpose, various mechanisms can be used to ensure that those
processes which want to operate files, memory CPU, and other hardware resources
should have proper authorization from the operating system.
For example, Memory addressing hardware helps you to confirm that a process can be
executed within its own address space. The time ensures that no process has control of
the CPU without renouncing it.
Lastly, no process is allowed to do its own I/O, to protect, which helps you to keep the
integrity of the various peripheral devices.
7. Networking
8. Command interpreter
User Interface
Program execution
I/O operations
File System manipulation
Communication
Error Detection
Resource Allocation
Protection
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 −
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.
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.
The OS handles routing and connection strategies, and the problems of contention and
security. Following are the major activities of an operating system with respect to
communication −
Error handling
Errors can occur anytime and anywhere. An error may occur in CPU, in I/O devices or in the
memory hardware. Following are the major activities of an operating system with respect to
error handling −
Resource Management
In case of multi-user or multi-tasking environment, resources such as main memory, CPU
cycles and files storage are to be allocated to each user or job. Following are the major
activities of an operating system with respect to resource management −
The OS manages all kinds of resources using schedulers.
CPU scheduling algorithms are used for better utilization of CPU.
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.
Protection refers to a mechanism or a way to control the access of programs, processes, or
users to the resources defined by a computer system. Following are the major activities of an
operating system with respect to protection −