OS Unit1
OS Unit1
INTRODUCTION
Computer System - Elements and organization; Operating System Overview - Objectives and
Functions - Evolution of Operating System; Operating System Structures – Operating System
Services - User Operating System Interface - System Calls – System Programs - Design and
Implementation - Structuring methods.
1.1.1 INTERRUPTS
➢ The Multiprocessor Systems have two (or more) processors, each with a single-core
CPU.
➢ The processors share the computer bus and sometimes the clock, memory, and
peripheral devices.
➢ The primary advantage of multiprocessor systems is increased throughput. That is,
by increasing the number of processors, we expect to get more work done in less
time.
Figure 1.6 Multicore Chip
Fig 1.8 A dual-core design with two cores on the same chip.
❖ The operating system prepares the list of tasks to be performed for the device
of the computer system.
❖ The operating system decides which device to use for which task. This
action becomes complicated when multiple tasks are to be performed
simultaneously in a computer system. The scheduling programs of the
operating system determine the order in which tasks are completed. It
performs these tasks based on the priority of performing the tasks given by
the user. It makes the tasks available based on the priority of the device.
➢ Security:
❖ The operating system takes care of the activities of the computer system
during various processes. This aborts the program if there are errors.
❖ The operating system sends instant messages to the user for any unexpected
error in the input/output device. It also provides security to the system when
the operating system is used in systems operated by multiple users. So that
illegal users cannot get data from the system.
1.5 EVOLUTION OF OPERATING SYSTEM
1.5.1 BATCH SYSTEMS
➢ Batch operating system is the operating system which analyses your input and groups
them into batches i.e.) data in each batch is of similar characteristics and then it
performs operation on each individual batch.
➢ The users of batch operating system do not interact with the computer directly. Each
user prepares his job on an off-line device like punch cards and submits it to the
computer operator.
➢ The operator then sorts programs into batches with similar requirements and submit
each group of job into computer.
➢ Jobs are processed in the order of submission i.e first come first served fashion
➢ OS keeps a number a jobs in memory and executes them without any manual
information
➢ When job completes its execution, its memory is released and the output for the job gets
copied into an output spool for later printing or processing.
➢ Batch system process a collection of jobs, called a batch. Batch is a sequence of user
jobs.
➢ Job is a predefined sequence of commands, programs and data that are combined into
single unit
➢ Spooling refers to putting jobs in buffer, a special area in memory or on a disk where
a device can access them when it is ready.
➢ The most common spooling application is print spooling
➢ Example of Batch Operating System is as follows.
❖ DOS (Disk operating system).
❖ IBM OS/2.
❖ Windows 1,2,3 95, 98 and ME
➢ As shown in fig 1.14, at the particular situation, job' A' is not utilizing the CPU time
because it is busy in I/ 0 operations. Hence the CPU becomes busy to execute the job
'B'. Another job C is waiting for the CPU for getting its execution time. So, in this state
the CPU will never be idle and utilizes maximum of its time. A program in execution is
called a "Process", "Job" or a "Task". The concurrent execution of programs improves
the utilization of system resources and enhances the system throughput as compared to
batch and serial processing.
➢ In the above figure user 5 is active but user 1, user 2, user 3, and user 4 are in waiting
state whereas user 6 is in ready status.
➢ As soon as the time slice of user 5 is completed, the control moves on to the next ready
user i.e., user 6. In this state user 2, user 3, user 4, and user 5 are in waiting state and
user 1 is in ready state. The process continues in the same way and so on.
➢ The time-shared systems are more complex than the multi-programming systems. In
time-shared systems multiple processes are managed simultaneously which requires an
adequate management of main memory so that the processes can be swapped in or
swapped out within a short time.
1.5.4 MULTIPROCESSOR OPERATING SYSTEMS
➢ More than one processor in close communication. All the processor share common
bus, clock, memory and peripheral devices.
➢ Increases system throughput buy getting more work done in less time.
➢ More Reliable i.e.) if one processor fails then the remaining processor will share the
work of the failed processor, thus preventing the failure of entire system
➢ Multiprocessor system is of two types
❖ Symmetric multiprocessing
❖ Asymmetric multiprocessing
1.5.4.1 Symmetric multiprocessor system (SMP)
➢ The kernel provides services for memory management, process management, file
management, and disk management.
➢ The kernel performs tasks in Kernel space. Executing processes and handling interrupts
are performed by kernel in kernel space.
➢ User performs his task in user area in memory.
➢ Memory is divided into user area and system area. This memory separation is made in
order to prevent user data and kernel data from interfering with each other.
➢ When a computer crashes it actually means the kernel has crashed. When a user
application program crashes it doesn’t meant kernel got crashed.
➢ A Kernel includes
❖ Scheduler
❖ Supervisor
❖ Interrupt Handler
❖ Memory Manager
➢ Scheduler allocates Kernels processing time to various processes.
➢ Supervisor grants permission to use computer system resources to each process
➢ Interrupt handler handles all requests from various hardware devices which compete
for Kernels services.
Fig:1.21 Main Components of OS
➢ The Kernel does not interact directly with the user. But it interacts with the shell, other
programs and hardware.
➢ Memory manager allocates space in memory for processes that requires the services of
kernel
➢ Types of Kernel
❖ Monolithic Kernel
❖ Micro Kernel
❖ Hybrid Kernel
❖ Exo-Kernel
➢ Monolithic kernel is a single large process running entirely in a single address space.
➢ The entire operating systems run as a single program in kernel mode.
➢ Basic OS services such as process management, memory management, interrupt
handling, IO communication, file system, device drivers, networking, etc all run in
kernel space. All kernel services exist and execute in kernel address space.
➢ Entire services are loaded on boot up and reside in memory and work is done using
system calls.
➢ Most of the operation performed by Kernel is via system call.ie)The kernel
communicates with the user process through system calls.
➢ A monolithic kernel can be easy to implement if we are ready to accept very high
latency [i.e. we service requests without worrying about the urgency of other requests.
➢ The examples of monolithic kernel based OSs are Linux, Unix.
Advantages:
➢ Simple to design and implement
➢ Simplicity provides speed on simple hardware
➢ Monolithic OS kernel is faster due to small source and compiled code size.
➢ Less code means also less bugs and security issues.
Disadvantages:
➢ The inclusion of all basic services in Kernel space has three big drawbacks
❖ Kernel size
❖ Lack of extensibility
❖ Bad Maintainability
❖ Fault tolerance is low
1.6.4.2 Microkernel
➢ The idea behind microkernel OS is to reduce the kernel to only basic process
communication and IO control and let other system services run in user space just like
any other normal processes.
➢ These services are called servers and kept separate and run in different address spaces.
➢ It provides facilities to various services which are running in user mode.
➢ There is a server for managing memory issues, one server does process management,
and another one manages drivers, and so on.
➢ Because the servers do not run in kernel space anymore, so called” context switches”
are needed, to allow user processes to enter privileged mode (and to exit again).
➢ Message passing method is used for communication between two processes.
➢ Mac OS and WinNT are two examples on microkernel OS architecture.
User Application
User Space
Libraries
Computer Hardware
Advantages:
➢ Service separation has the advantage that if one service (called a server) fails others
can still work so reliability is the primary feature. For example, if a device driver
crashes does not cause the entire system to crash. Only that driver needs to be
restarted rather than having the entire system die. This means more persistence as
one server can be substituted with another.
➢ Maintenance is easier.
➢ Different services are built into special modules which can be loaded or unloaded
when needed.
➢ Message passing allows independent communication and allows extensibility
➢ Microkernel architecture supports object oriented operating systems.
➢ Modular design helps to improve reliability.
➢ Microkernel architecture support flexibility ie) User can add or remove services
according to requirement
S.NO Monolithic Kernel Micro Kernel
1 Kernel size is large Kernel size is small
2 OS is complex to design OS is easy to design and
install
3 Request may be serviced Request is serviced
faster slower than Monolithic
Kernel
4 All the operating system Kernel provides only
services are included in IPC and low level
Kernel device management
services
5 No message passing and no Microkernel requires
context switching are required message passing and
while kernel is performing the context switches
job
➢ An Operating System provides services to both the users and to the programs.
❖ It provides programs an environment to execute.
❖ It provides users the services to execute the programs in a convenient manner.
➢ Following are a few common services provided by an operating system −
❖ Program execution
❖ I/O operations
❖ File System manipulation
❖ Communication
❖ Error Detection
❖ Resource Allocation
❖ Protection
1.7.1 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.
1.7.2 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.
1.7.3 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.
➢ A file system is normally organized into directories for easy navigation and usage.
These directories may contain files and other directions. Following are the major
activities of an operating system with respect to file management −
➢ 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 −
❖ Two processes often require data to be transferred between them
❖ Both the processes can be on one computer or on different computers but are
connected through a computer network.
❖ Communication may be implemented by two methods, either by Shared
Memory or by Message Passing.
1.7.5 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 −
❖ The OS constantly checks for possible errors.
❖ The OS takes an appropriate action to ensure correct and consistent computing.
1.7.6 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.
1.7.7 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 −
❖ The OS ensures that all access to system resources is controlled.
❖ The OS ensures that external I/O devices are protected from invalid access
attempts.
❖ The OS provides authentication features for each user by means of passwords.
1.9.3 Three general methods exist for passing parameters to the OS:
1. Parameters can be passed in registers.
2. When there are more parameters than registers, parameters can be stored in a block and
the block address can be passed as a parameter to a register.
3. Parameters can also be pushed on or popped off the stack by the operating system.
➢ System call under this category includes calls to create a new process, terminate a
process, setting and retrieving process attributes (such as process priority, its maximum
allowable execution time, etc), forcing a process to wait for some time or some event
to occur, etc.
➢ 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.
1.9.1.2 File manipulation
➢ System call under this category include calls to create, delete, open ,close read and
write a file.
1.9.1.3 Device Management
➢ System calls under this category includes calls to request for device, releasing it and
performing some operations (such as read or write) with the device.
1.9.1.4 Information Maintenance
➢ System calls under this category includes calls to return information about the
system, such as systems current date and time, number of current users, version of
operating systems, amount of free memory, etc.
1.9.1.5 Communication
➢ There are two models of interprocess communication, the message-passing model
and the shared memory model.
➢ In a shared memory model, a process uses memory for communication. One process
will create a memory partition which other processes can access. A shared segment
can be attached multiple times by the same process
➢ In message passing communication is done either direct or indirect
❖ In direct communication process address each other by their PID assigned
to them by OS.
❖ In indirect communication messages are sent and received via mailbox
Table 1.4: Examples of WINDOWS and UNIX system calls
➢ The Multiprocessor Systems have two (or more) processors, each with a single-core
CPU.
➢ The processors share the computer bus and sometimes the clock, memory, and
peripheral devices.
8. What is NUMA
➢ NUMA represents Non-uniform Memory Access. NUMA is a multiprocessor
model in which each processor is connected with the dedicated memory.
➢ Memory access between processor core to main memory is not uniform.
Multiprocessor Multicore
Multiprocessors are systems with two or A Multicore Processor combines two or
more processing units. Each Processor share more Multi Processor on a Single Chip. It is
the Main memory and I/O Devices also called as Chip Multiprocessor
Processor performance is high. Processor performance is low.
Processor power consumption is high Processor power consumption is low
Executes multiple programs faster. Executes a single program faster.
Have more traffic Have less traffic.
38. Differentiate System calls and System programs.