Unit I

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

[Type text]

Chapter 1 Marks 10

Overview of Operating System

1.0 INTRODUCTION
Computer software can be divided into two main categories: application software and system software.
Application software consists of the programs for performing tasks particular to the machine’s utilization.
This software is designed to solve a particular problem for users. Examples of application software include
spreadsheets, database systems, desktop publishing systems, program development software, and games.

On the other hand, system software is more transparent and less noticed by the typical computer user. This
software provides a general programming environment in which programmers can create specific
applications to suit their needs. This environment provides new functions that are not available at the
hardware level and performs tasks related to executing the application program. System software acts as an
interface between the hardware of the computer and the application software that users need to run on the
computer. The most important type of system software is the operating system.

An Operating System (OS) is a collection of programs that acts as an interface between a user of a computer
and the computer hardware. The purpose of an operating system is to provide an environment in which a user
may execute the programs.

Operating Systems are viewed as resource managers. The main resource is the computer hardware in the
form of processors, storage, input/output devices, communication devices, and data. Some of the operating
system functions are: implementing the user interface, sharing hardware among users, allowing users to share
data among themselves, preventing users from interfering with one another, scheduling resources among
users, facilitating input/output, recovering from errors, accounting for resource usage, facilitating parallel
operations, organizing data for secure and rapid access, and handling network communications.

What Operating Systems Do


We begin our discussion by looking at the operating system’s role in the overall computer system. A
computer system can be divided roughly into four components: the hardware, the operating system, the
application programs, and the users (Figure 1.1).

[Type text]
[Type text]

Figure 1.1 Abstract view of the components of a computer system.


The hardware—the central processing unit (CPU), the memory, and the input/output (I/O)
devices—provides the basic computing resources for the system. The application programs—such as word
processors, spreadsheets, compilers, and Web browsers—define the ways in which these resources are used
to solve users’ computing problems. The operating system controls the hardware and coordinates its use
among the various application programs for the various users.

We can also view a computer system as consisting of hardware, software, and data. The operating system
provides the means for proper use of these resources in the operation of the computer system. An operating
system is similar to a government. Like a government, it performs no useful function by itself. It simply
provides an environment within which other programs can do useful work.

To understand more fully the operating system’s role, we next explore operating systems from two
viewpoints: that of the user and that of the system.

1.1.1 User View


The user’s view of the computer varies according to the interface being used. Most computer users sit in
front of a PC, consisting of a monitor, keyboard, mouse, and system unit. Such a system is designed for one
user to monopolize its resources. The goal is to maximize the work (or play) that the user is performing. In
this case, the operating system is designed mostly for ease of use, with some attention paid to performance
and none paid to resource utilization—how various hardware and software resources are shared.
Performance is, of course, important to the user; but such systems are optimized for the single-user
experience rather than the requirements of multiple users.

[Type text]
[Type text]

1.1.2 System View


From the computer’s point of view, the operating system is the program most intimately involved with the
hardware. In this context, we can view an operating system as a resource allocator. A computer system has
many resources that may be required to solve a problem: CPU time, memory space, file-storage space, I/O
devices, and so on. The operating system acts as the manager of these resources. Facing numerous and
possibly conflicting requests for resources, the operating system must decide how to allocate them to specific
programs and users so that it can operate the computer system efficiently and fairly. As we have seen,
resource allocation is especially important where many users access the same mainframe or minicomputer.

A slightly different view of an operating system emphasizes the need to control the various I/O devices and
user programs. An operating system is a control program. A control program manages the execution of
user programs to prevent errors and improper use of the computer. It is especially concerned with the
operation and control of I/O devices.

1.2.1 Computer-System Operation


A modern general-purpose computer system consists of one or more CPUs and a number of device
controllers connected through a common bus that provides access to shared memory (Figure 1.2). Each
device controller is in charge of a specific type of device (for example, disk drives, audio devices, or video
displays). The CPU and the device controllers can execute in parallel, competing for memory cycles. To
ensure orderly access to the shared memory, a memory controller synchronizes access to the memory.

For a computer to start running—for instance, when it is powered up or rebooted—it needs to have an initial
program to run. This initial program, or bootstrap program, tends to be simple. Typically, it is stored within
the computer hardware in read-only memory (ROM) or electrically erasable programmable read-only
memory (EEPROM), known by the general term firmware. It initializes all aspects of the system, from CPU
registers to device controllers to memory contents. The bootstrap program must know how to load the
operating system and how to start executing that system. To accomplish this goal, the bootstrap program
must locate the operating-system kernel and load it into memory.

Once the kernel is loaded and executing, it can start providing services to the system and its users. Some
services are provided outside of the kernel, by system programs that are loaded into memory at boot time to
become system processes, or system daemons that run the entire time the kernel is running.

[Type text]
[Type text]

Figure 1.2 A modern computer system.

The occurrence of an event is usually signaled by an interrupt from either the hardware or the software.
Hardware may trigger an interrupt at any time by sending a signal to the CPU, usually by way of the system
bus. Software may trigger an interrupt by executing a special operation called a system call (also called a
monitor call).

1.2.2 Storage Structure


The CPU can load instructions only from memory, so any programs to run must be stored there. General-
purpose computers run most of their programs from rewritable memory, called main memory (also called
random-access memory, or RAM). Main memory commonly is implemented in a semiconductor technology
called dynamic random-access memory (DRAM).

Computers use other forms of memory as well. We have already mentioned read-only memory, ROM) and
electrically erasable programmable read-only memory, EEPROM). Because ROM cannot be changed, only
static programs, such as the bootstrap program described earlier, are stored there. The immutability of ROM
is of use in game cartridges. EEPROM can be changed but cannot be changed frequently and so contains
mostly static programs. For example, smartphones have EEPROM to store their factory-installed programs.

Ideally, we want the programs and data to reside in main memory permanently. Thisarrangement usually is
not possible for the following two reasons:
1. Main memory is usually too small to store all needed programs and data permanently.
2. Main memory is a volatile storage device that loses its contents when power is turned offor otherwise
lost.

[Type text]
[Type text]

Thus, most computer systems provide secondary storage as an extension of main memory. The main
requirement for secondary storage is that it be able to hold large quantities ofdata permanently.

The most common secondary-storage device is a magnetic disk, which provides storage for both programs
and data. Most programs (system and application) are stored on a disk until they are loaded into memory.
Many programs then use the disk as both the source and the destination of their processing. Hence, the proper
management of disk storage is of central importance to a computer system,

Figure 1.3 Storage-device hierarchy.

1.8 FUNCTIONS OF OS
The main functions of an operating system are as follows:
1. Process Management
2. Memory Management
3. Secondary Storage Management
4. I/O Management
5. File Management
6. Protection
7. Networking Management
8. Command Interpretation.

1.8.1 Process Management


The CPU executes a large number of programs. While its main concern is the execution of user programs,
the CPU is also needed for other system activities. These activities are called

[Type text]
[Type text]

processes. A process is a program in execution. Typically, a batch job is a process. A time- shared user
program is a process. A system task, such as spooling, is also a process. For now, a process may be
considered as a job or a time- shared program, but the concept is actually more general.
The operating system is responsible for the following activities in connection with processes management:
1. The creation and deletion of both user and system processes
2. The suspension and resumption of processes.
3. The provision of mechanisms for process synchronization
4. The provision of mechanisms for deadlock handling.More
details can be studied in the Unit-2 of this course.

1.8.2 Memory Management


Memory is the most expensive part in the computer system. Memory is a large array of words or bytes, each
with its own address. Interaction is achieved through asequence of reads or writes of specific memory
address. The CPU fetches from and stores in memory.
There are various algorithms that depend on the particular situation to manage the memory. Selection of a
memory management scheme for a specific system depends upon many factors, but especially upon the
hardware design of the system. Each algorithm requires its own hardware support.
The operating system is responsible for the following activities in connection with memory management.
1. Keep track of which parts of memory are currently being used and by whom.
2. Decide which processes are to be loaded into memory when memory space becomesavailable.
3. Allocate and deallocate memory space as needed.
Memory management techniques will be discussed in great detail in Unit 3.

1.8.3 Secondary Storage Management


The main purpose of a computer system is to execute programs. These programs, together with the data they
access, must be in main memory during execution. Since the main memory is too small to permanently
accommodate all data and program, the computer system must provide secondary storage to backup main
memory. Most modem computer systems use disks as the primary on-line storage of information, of both
programs and data. Most programs, like compilers, assemblers, sort routines, editors, formatters, and so on,
are stored on the disk until loaded into memory, and then use the disk as both the source and destination of
their processing. Hence the proper management of disk storage is of central importance to a computer
system.
There are few alternatives. Magnetic tape systems are generally too slow. In addition, they are limited to
sequential access. Thus tapes are more suited for storing infrequently used files, where speed is not a primary
concern.
The operating system is responsible for the following activities in connection with disk management:

[Type text]
[Type text]

1. Free space management


2. Storage allocation
3. Disk scheduling.
More details can be studied in Unit-4 of this course.

1.8.4 I/O Management


One of the purposes of an operating system is to hide the peculiarities or specific hardware devices from the
user. For example, in UNIX, the peculiarities of I/O devices are hidden fromthe bulk of the operating system
itself by the I/O system. The operating system is responsible for the following activities in connection to I/O
management:
1. A buffer caching system
2. To activate a general device driver code
3. To run the driver software for specific hardware devices as and when required. More details
can be studied in the Unit-3 of Block-2 of this course.

1.8.5 File Management


File management is one of the most visible services of an operating system.
Computers can store information in several different physical forms: magnetic tape, disk, and drum are the
most common forms. Each of these devices has its own characteristicsand physical organization.

For convenient use of the computer system, the operating system provides a uniform logical view of
information storage. The operating system abstracts from the physical properties of its storage devices to
define a logical storage unit, the file. Files are mapped, by the operating system, onto physical devices.

A file is a collection of related information defined by its creator. Commonly, files represent programs (both
source and object forms) and data. Data files may be numeric, alphabetic or alphanumeric. Files may be free-
form, such as text files, or may be rigidly formatted. In general a file is a sequence of bits, bytes, lines or
records whose meaning is defined by its creator and user. It is a very general concept.

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 is responsible for the following activities in connection to the file management:
1. The creation and deletion of files.
2. The creation and deletion of directory.
3. The support of primitives for manipulating files and directories.
4. The mapping of files onto disk storage.
5. Backup of files on stable (non volatile) storage.

[Type text]
[Type text]

6. Protection and security of the files.

1.8.6 Protection
The various processes in an operating system must be protected from each other’s activities. For that
purpose, various mechanisms which can be used to ensure that the files, memory segment, CPU and other
resources can be operated on only by those processes that have gained proper authorization from the
operating system.
For example, memory addressing hardware ensures that a process can only execute within its own address
space. The timer ensures that no process can gain control of the CPU without relinquishing it. Finally, no
process is allowed to do its own I/O, to protect the integrity of the various peripheral devices. Protection
refers to a mechanism for controlling the access of programs, processes, or users to the resources defined by
a computer controls to be imposed, together with some means of enforcement.
Protection can improve reliability by detecting latent errors at the interfaces between component subsystems.
Early detection of interface errors can often prevent contamination of a healthy subsystem by a subsystem
that is malfunctioning. An unprotected resource cannot defend against use (or misuse) by an unauthorized or
incompetent user.

1.8.7 Networking
A distributed system is a collection of processors that do not share memory or a clock. Instead, each processor
has its own local memory, and the processors communicate witheach other through various
communication lines, such as high speed buses or telephonelines. Distributed systems vary in size and
function. They may involve microprocessors,workstations, minicomputers, and large general purpose
computer systems.
The processors in the system are connected through a communication network, which can be configured in
the number of different ways. The network may be fully or partially connected. The communication network
design must consider routing and connection strategies and the problems of connection and security.
A distributed system provides the user with access to the various resources the system maintains. Access to a
shared resource allows computation speed-up, data availability, and reliability.

1.8.8 Command Interpretation


One of the most important components of an operating system is its command interpreter. The command
interpreter is the primary interface between the user and the rest of the system.
Many commands are given to the operating system by control statements. When a new job is started in a
batch system or when a user logs-in to a time-shared system, a program which reads and interprets control
statements is automatically executed. This program is variously called (1) the control card interpreter, (2) the
command line interpreter, (3) the shell (in Unix), and so on. Its function is quite simple: get the next
command statement, and execute it.

[Type text]
[Type text]

The command statements themselves deal with process management, I/O handling, secondary storage
management, main memory management, file system access, protection,and networking.
Figure depicts the role of the operating system in coordinating all the functions.

Types of Operating Systems

An Operating System performs all the basic tasks like managing file, process, and memory.Thus operating
system acts as manager of all the resources, i.e. resource manager. Thus operating system becomes an
interface between user and machine.
Types of Operating Systems: Some of the widely used operating systems are as follows-

1. Batch OS –

This type of operating system does not interact with the computer directly. The user has to submit a job
(written on cards or tape) to a computer operator. There is an operator which takes similar jobs having same
requirement and group them into batches. It is the responsibility of operator to sort the jobs with similar
needs. Then computer operator places a batch of several jobs on an input device. Jobs are batched together
by type of languages and requirement. Then a special program, the monitor, manages the execution of each
program in the batch. The monitor is always in the main memory and available for execution.

[Type text]
[Type text]

2. Multi programming –
In a modern computing system, there are usually several concurrent application processes which want to
execute. Now it is the responsibility of the Operating System to manage allthe processes
effectively and efficiently. One of the most
important aspects of an Operating System is to multi program. In a computer system, there are
multiple processes waiting to be executed, i.e. they are waiting when the CPU will be allocated to them and
they begin their execution. These processes are also known as jobs. Now the main memory is too small to
accommodate all ofthese processes or jobs into it. Thus, these processes are initially kept in an area called job
pool. This job pool consists of all those processes awaiting allocation of main memory and CPU.
CPU selects one job out of all these waiting jobs, brings it from the job pool to main memory and starts
executing it. The processor executes one job until it is interrupted by some external factor or it goes for an
I/O task.

Non-multi programmed system’s working –


 In a non multi programmed system, As soon as one job leaves the CPU and goes for some other task
(say I/O ), the CPU becomes idle. The CPU keeps waiting and waiting until this job (which was
executing earlier) comes back and resumes its execution with the CPU. So CPU remains free for all this
while.
 Now it has a drawback that the CPU remains idle for a very long period of time. Also, other jobs which
are waiting to be executed might not get a chance to execute becausethe CPU is still
allocated to the earlier job. This poses a very serious problem that even though
other jobs are ready to execute, CPU is not allocated to them as the CPU is allocated to a job which is
not even utilizingit (as it is busy in I/O tasks).
 It cannot happen that one job is using the CPU for say 1 hour while the others have been waiting in the
queue for 5 hours. To avoid situations like this and come up with efficient utilization of CPU, the
concept of multi programming came up.

[Type text]
[Type text]

The main idea of multi programming is to maximize the CPU time.


Multi programmed system’s working –
 In a multi-programmed system, as soon as one job goes for an I/O task, the Operating System interrupts
that job, chooses another job from the job pool (waiting queue), gives CPU to this new job and starts
its execution. The previous job keeps doing its I/O operation while this new job does CPU bound tasks.
Now say the second job also goes for an I/O task, the CPU chooses a third job and starts executing it.
As soon as a job completes its I/O operation and comes back for CPU tasks, the CPU is allocated to it.
 In this way, no CPU time is wasted by the system waiting for the I/O task to becompleted.
Therefore, the ultimate goal of multi programming is to keep the CPU busy as long as there are
processes ready to execute. This way, multiple programs can be executed on a single processor by
executing a part of a program at one time, a part of another program after this, then a part of another
program and so on, hence executing multipleprograms. Hence, the CPU never remains idle.
In the image below, program A runs for some time and then goes to waiting state. In the mean time program
B begins its execution. So the CPU does not waste its resources and gives program B an opportunity to run.

3. Multitasking –
As the name itself suggests, multi tasking refers to execution of multiple tasks (say processes, programs,
threads etc.) at a time. In the modern operating systems, we are able to play MP3 music, edit documents in
Microsoft Word, surf the Google Chrome all simultaneously, this is accomplished by means of multi tasking.
Multitasking is a logical extension of multi programming. The major way in which multitasking differs from
multi programming is that multi programming works solely on the concept of context switching whereas
multitasking is based on time sharing alongside the concept of context switching.

[Type text]
[Type text]

Multi tasking system’s working –


 In a time sharing system, each process is assigned some specific quantum of time for which a process is
meant to execute. Say there are 3 processes P1, P2, P3 ready to execute. So each of them are assigned
some time quantum for which they will execute
e.g time quantum of 2 nanoseconds (2 ns). As one process begins execution (say P1), it executes for
that quantum of time (2 ns). After 2 ns the CPU starts the execution of the other process (say P2) for the
specified quantum of time.
 Thus the CPU makes the processes to share time slices between them and execute accordingly. As soon
as time quantum of one process expires, another process begins its execution.
 Here also basically a context switch is occurring but it is occurring so fast that the user is able to
interact with each program separately while it is running. This way, the user is given the illusion that
multiple processes/ tasks are executing simultaneously. But actually only one process/ task is executing
at a particular instant of time. In multitasking, time sharing is best manifested because each running
process takes only afair quantum of the CPU time.
In a more general sense, multitasking refers to having multiple programs, processes, tasks, threads running at
the same time. This term is used in modern operating systems when multiple tasks share a common
processing resource (e.g., CPU and Memory).

 As depicted in the above image, At any time the CPU is executing only one task whileother tasks
are waiting for their turn. The illusion of parallelism is achieved when theCPU is reassigned to
another task. i.e all the three tasks A, B and C are appearing to occur simultaneously because of
time sharing.
 So for multitasking to take place, firstly there should be multiprogramming i.e. presence of multiple
programs ready for execution. And secondly the concept of timesharing.
4. Multiprocessing –
In a uni-processor system, only one process executes at a time.
Multiprocessing is the use of two or more CPUs (processors) within a single Computer system. The term
also refers to the ability of a system to support more than one processor

[Type text]
[Type text]

within a single computer system. Now since there are multiple processors available, multiple processes
can be executed at a time. These multi processors share the computerbus, sometimes the clock, memory
and peripheral devices also.

Multi processing system’s working –


 With the help of multiprocessing, many processes can be executed simultaneously. Sayprocesses P1,
P2, P3 and P4 are waiting for execution. Now in a single processor system, firstly one process will
execute, then the other, then the other and so on.
 But with multiprocessing, each process can be assigned to a different processor for its execution. If its a
dual-core processor (2 processors), two processes can be executed simultaneously and thus will be two
times faster, similarly a quad core processor will befour times as fast as a single processor.
Why use multi processing –
 The main advantage of multiprocessor system is to get more work done in a shorter period of time.
These types of systems are used when very high speed is required to process a large volume of data.
Multi processing systems can save money in comparison to single processor systems because the
processors can share peripheralsand power supplies.
 It also provides increased reliability in the sense that if one processor fails, the work does not halt, it
only slows down. e.g. if we have 10 processors and 1 fails, then the work does not halt, rather the
remaining 9 processors can share the work of the 10thprocessor. Thus the whole system runs only
10 percent slower, rather than failing altogether.

Multiprocessing refers to the hardware (i.e., the CPU units) rather than the software (i.e., running
processes). If the underlying hardware provides more than one processor then thatis multiprocessing. It is
the ability of the system to leverage multiple processors’ computingpower.

Difference between Multi programming and Multi processing –


 A System can be both multi programmed by having multiple programs running at the same time and
multiprocessing by having more than one physical processor. The difference between
multiprocessing and multi programming is that Multiprocessing is

[Type text]
[Type text]

basically executing multiple processes at the same time on multiple processors,whereas multi
programming is keeping several programs in main memory and executing them concurrently
using a single CPU only.
 Multiprocessing occurs by means of parallel processing whereas Multi programmingoccurs by
switching from one process to other (phenomenon called as context switching).

[Type text]

You might also like