Pos Notes Unit 1
Pos Notes Unit 1
UNIT-I:
Computer System and Operating System Overview: Overview of computer operating
systems, operating system functions, operating system structure and system calls,
Evaluation of Operating Systems.
Managing Input-Output unit: Operating System also allows the computer to manage its own
resources such as memory, monitor, keyboard, printer etc. Management of these resources is
required for an effective utilization.The operating system controls the various system input-
output resources and allocates them to the users or programs as per their requirement.
Consistent user interface: Operating System provides the user an easy-to-work user interface,
so the user doesn’t have to learn a different UI every time and can focus on the content and be
productive as quickly as possible. Operating System provides templates, UI components to
make the working of a computer, really easy for the user.
Multitasking: Operating System manages memory and allow multiple programs to run in their
own space and even communicate with each other through shared memory. Multitasking gives
users a good experience as they can perform several tasks on a computer at a time.
An Operating system (OS) is a software which acts as an interface between the end user
and computer hardware. Every computer must have at least one OS to run other programs. An
application like Chrome, MS Word, Games, etc needs some environment in which it will run
and perform its task. The OS helps you to communicate with the computer without knowing
how to speak the computer's language. It is not possible for the user to use any computer or
mobile device without having an operating system.
1.2 Operating System Functions
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 multi-programming, 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 multi-programming 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.
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.
An operating system is a construct that allows the user application programs to interact
with the system hardware. Since the operating system is such a complex structure, it should be
created with utmost care so it can be used and modified easily. An easy way to do this is to
create the operating system in parts. Each of these parts should be well defined with clear
inputs, outputs and functions.
Simple Structure
There are many operating systems that have a rather simple structure. These started as small
systems and rapidly expanded much further than their scope. A common example of this is
MS-DOS. It was designed simply for a niche amount for people. There was no indication that it
would become so popular.
An image to illustrate the structure of MS-DOS is as follows:
It is better that operating systems have a modular structure, unlike MS-DOS. That would lead
to greater control over the computer system and its various applications. The modular structure
would also allow the programmers to hide information as required and implement internal
routines as they see fit without changing the outer specifications.
Layered Structure
One way to achieve modularity in the operating system is the layered approach. In this, the
bottom layer is the hardware and the topmost layer is the user interface.
An image demonstrating the layered approach is as follows:
As seen from the image, each upper layer is built on the bottom layer. All the layers hide some
structures, operations etc from their upper layers.
One problem with the layered structure is that each layer needs to be carefully defined. This is
necessary because the upper layers can only use the functionalities of the layers below them.
Monolithic/Kernel-Based Approach
Functionality of the OS is invoked with simple function calls within the kernel, which is one
large program. Device drivers are loaded into the running kernel and become part of the kernel.
Figure below is an abstract view of a kernel-based OS. The kernel is the core of the OS; it provides
a set of functions and services to support various OS functionalities. The rest of the OS is
organized as a set of non-kernel routines, which implement operations on processes and
resources that are of interest to users, and a user interface.
The micro-kernel was developed in the early 1990s to overcome the problems concerning
portability, extensibility, and reliability of kernels. A micro-kernel is an essential core of OS
code, thus it contains only a subset of the mechanisms typically included in a kernel and
supports only a small number of system calls, which are heavily tested and used.
This structures the operating system by removing all nonessential portions of the kernel and
implementing them as system and user level programs.Generally they provide minimal process
and memory management, and a communications facility.Communication between components
of the OS is provided by message passing.
The benefits of the micro-kernel 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 micro-kernel also provides more security and reliability.
In a hybrid operating system, two operating system may execute on a single device. This
can be done by dividing the memory and the processor between the operating systems. All
the system resources would be shared between them.
The two operating systems on a computer system may include a full-fledged operating
system and a lightweight operating system. Both of these operating systems would fulfill
different sets of tasks depending on their capabilities.
One of the ways to install the two operating systems is to bootstrap the first operating
system with all the system resources. Then half of the system resources are allocated to the
first operating system and the second operating system is bootstrapped with the remaining
system resources.
Another method to handle two operating systems on the same device is to use hypervisors.
This is a software layer between the hardware and the guest operating system which
provides a virtualized hardware to the guest operating system.
Both the operating systems in the hybrid environment may be aware of the other operating
system and share resources with each other. For example, both the operating systems may
have direct access to the hardware components such as memory, processor, BIOS etc and
the operating systems may execute concurrently on the system.
Hybrid Kernel
The kernel is the core part of the operating system as it manages the operations of the computer
as well as the hardware. The hybrid kernel attempts to combine the features and aspects of the
microkernel and the monolithic kernel. This means that the kernel structure should be similar to
a microkernel but the structure should be implemented like a monolithic kernel.
A well-known example of the hybrid kernel is the Microsoft Windows NT kernel. This kernel
handles all the operating systems in the Windows NT family. It is called a hybrid kernel instead
of a monolithic kernel as the emulation subsystems run on the user mode rather than the kernel
mode, unlike in monolithic kernel.
The NT kernel cannot be called a microkernel as well. This is because almost all the system
components run on the same address space as the kernel, which is a feature of the monolithic
kernel.
A figure that illustrates the structure of the Microsoft Windows NT kernel is as follows:
There are mainly two layers in the Windows NT operating system architecture i.e user mode
and kernel mode. The user mode contains the Integral Subsystems and Environmental
Subsystems with various modules in each of them.
The executive part of the kernel mode contains the executive services and object manager. The
executive services include I/O manager, IPC manager, process manager etc.
Apart from the executive mode, the kernel mode contains the kernel mode drivers, the
microkernel and the hardware abstraction layer. The hardware abstraction layer is connected to
the hardware.
System Calls in Operating Systems:
The interface between a process and an operating system is provided by system calls. In
general, system calls are available as assembly language instructions. They are also included in
the manuals used by the assembly level programmers. System calls are usually made when a
process in user mode requires access to a resource. Then it requests the kernel to provide the
resource via a system call.
A figure representing the execution of the system call is given as follows:
As can be seen from this diagram, the processes execute normally in the user mode until a
system call interrupts this. Then the system call is executed on a priority basis in the kernel
mode. After the execution of the system call, the control returns to the user mode and execution
of user processes can be resumed.
In general, system calls are required in the following situations:
If a file system requires the creation or deletion of files. Reading and writing from files
also require a system call.
Creation and management of new processes.
Network connections also require system calls. This includes sending and receiving
packets.
Access to a hardware devices such as a printer, scanner etc. requires a system call.
● Multiprogramming didn't provide the user interaction with the computer system.
● Time sharing or Multitasking is a logical extension of Multiprogramming that provides user
interaction.
● There are more than one user interacting the system at the same time
● The switching of CPU between two users is so fast that it gives the impression to user that he
is
only working on the system but actually it is shared among different users.
● CPU bound is divided into different time slots depending upon the number of users using the
system.
● just as multiprogramming allows the processor to handle multiple batch jobs at a time,
multiprogramming can also be used to handle multiple interactive jobs. In this latter case, the
technique is referred to as time sharing, because processor time is shared among multiple users
● A multitasking system uses CPU scheduling and multiprogramming to provide each user
with a
small portion of a time shared computer. Each user has at least one separate program in
memory.
● Multitasking are more complex than multiprogramming and must provide a mechanism for
jobs
synchronization and communication and it may ensure that system does not go in deadlock.
Although batch processing is still in use but most of the system today available uses the
concept of Serial Processing:
● Early computer from late 1940 to the mid 1950.
● The programmer interacted directly with the computer hardware.
● These machine are called bare machine as they don't have OS.
● Every computer system is programmed in its machine language.
● Uses Punch Card, paper tapes and language translator
These system presented two major problems.
1. Scheduling
2. Set up time:
Scheduling:
Used sign up sheet to reserve machine time. A user may sign up for an hour but finishes his job
in 45
minutes. This would result in wasted computer idle time, also the user might run into the
problem not finish his job in allotted time.
Set up time:
A single program involves:
● Loading compiler and source program in memory
● Saving the compiled program (object code)
● Loading and linking together object program and common function
Each of these steps involves the mounting or dismounting tapes on setting up punch cards. If an
error occur user had to go the beginning of the set up sequence. Thus, a considerable amount of
time is spent
in setting up the program to run.
This mode of operation is turned as serial processing ,reflecting the fact that users access the
computer
in series.
Simple Batch Processing:
● Early computers were very expensive, and therefore it was important to maximize processor
utilization.
● The wasted time due to scheduling and setup time in Serial Processing was unacceptable.
● To improve utilization, the concept of a batch operating system was developed.
● Batch is defined as a group of jobs with similar needs. The operating system allows users to
form batches. Computer executes each batch sequentially, processing all jobs of a batch
considering them as a single process called batch as the monitor. With this type of OS, the user
no longer has direct access to the processor. Instead, the
user submits the job on cards or tape to a computer operator, who batches the jobs together
sequentially
and places the entire batch on an input device, for use by the monitor. Each program is
constructed to
branch back to the monitor when it completes processing, at which point the monitor
automatically
begins loading the next program.
With a batch operating system, processor time alternates between execution of user programs
and
execution of the monitor. There have been two sacrifices: Some main memory is now given
over to the
monitor and some processor time is consumed by the monitor. Both of these are forms of
overhead.
Multiprogrammed Batch System:
A single program cannot keep either CPU or I/O devices busy at all times. Multiprogramming
increases
CPU utilization by organizing jobs in such a manner that CPU has always one job to execute. If
computer is required to run several programs at the same time, the processor could be kept
busy for the
most of the time by switching its attention from one program to the next. Additionally I/O
transfer
could overlap the processor activity i.e, while one program is awaiting for an I/O transfer,
another
program can use the processor. So CPU never sits idle or if comes in idle state then after a very
small
time it is again busy. This is illustrated in fig below.
Distributed Operating Systems
In a distributed system, the different machines are connected to a network and each machine
has its own processor and owns local memory.
In this system, the operating systems on all the machines work together to manage the
collective network resource.
It can be classified into two categories:
Client-Server systems
Peer-to-Peer systems
Advantages of distributed systems:-
Resources Sharing
Computation speed up – load sharing
Reliability
Communications
Requires networking infrastructure.
Local area networks (LAN) or Wide area networks (WAN)
Desktop Systems/Personal Computer Systems
The PC operating system is designed for maximizing user convenience and responsiveness.
This system is neither multi-user nor multitasking.
These systems include PCs running Microsoft Windows and the Apple Macintosh. The MS-
DOS operating system from Microsoft has been superseded by multiple flavors of Microsoft
Windows and IBM has upgraded MS-DOS to the OS/2 multitasking system.
Real-Time Operating Systems (RTOS)
A real-time operating system (RTOS) is a multitasking operating system intended for
applications with fixed deadlines (real-time computing). Such applications include some small
embedded systems, automobile engine controllers, industrial robots, spacecraft, industrial
control, and some large-scale computing systems.
The real-time operating system can be classified into two categories:-
A hard real-time system guarantees that critical tasks be completed on time. This goal requires
that all delays in the system be bounded, from the retrieval of stored data to the time that it
takes the operating system to finish any request made of it. Such time constraints dictate the
facilities that are available in hard real-time systems.
A soft real-time system is a less restrictive type of real-time system. Here, a critical real-time
task gets priority over other tasks and retains that priority until it completes. The soft real-time
system can be mixed with other types of systems. Due to less restriction, they are risky to use
for industrial control and robotics.