Operating System
Operating System
MUWANGUZI DERRICK
1
Acknowledgments
I would like to extend my heartfelt gratitude to those who have made the completion of this
book possible.
Firstly, I would like to thank PR KIWANUKA FRED, whose insightful feedback and
encouragement were invaluable throughout the writing process. Your expertise and
guidance have greatly enriched the content of this book.
A special thanks to my family and friends for their unwavering support and patience. Your
understanding and encouragement have been a source of strength and motivation.
I would like to acknowledge CLICK CAFE, whose professionalism and dedication helped
transform my manuscript into the finished book. Your meticulous editing and valuable
suggestions have significantly improved the quality of this work.
Thank you to everyone who has contributed to this project. Your support has made this
journey both possible and rewarding.
MUWANGUZI DERRICK
2th/09/2024
Email:[email protected]
Email:[email protected]
Tel:
2
6
INTERACTION OF USER AND COMPUTER
Contents
● Device drivers
● System utility software—Antivirus, data compression, cryptographic, disk
compression, disk partitioning, disk cleaner, backup, system profiling, and
network manager
● Programming language—Machine language, assembly language, high-
level language, and different generations of programming languages
● Translator software—Assembler, compiler, and interpreter
The computer, as a machine, can do nothing for you without the software.
Software is required for the functioning of computers. Software programs instruct
computers about the actions to be performed, so as to get the desired output. The
purpose of this chapter is to introduce you to the different categories of software.
INTRODUCTION
3
Users can use the same computer hardware for writing a report or for running a payroll
program. The components like monitor, keyboard, processor, and mouse, constitute the
hardware (Figure 6.1). In this chapter, we will discuss the different categories of computer
software.
TYPES OF SOFTWARE
System software provides the basic functions that are performed by the computer. It is necessary
for the functioning of a computer. Application software is used by the users to perform specific
tasks. The user may choose the appropriate application software, for performing a specific task,
which provides the desired functionality. The system software interacts with hardware at one
end and with application software at the other end. The application software interacts with the
system software and the users of the computer. Figure 6.2 shows the hierarchy of software,
hardware and users.
4
Figure 6.2 Software hierarchy
SYSTEM SOFTWARE
System software provides basic functionality to the computer. System software is required for
the working of the computer itself. The user of a computer does not need to be aware about the
functioning of system software, while using the computer. For example, when you buy a
computer, the system software would also include different device drivers. When you request
for using any of the devices, the corresponding device driver software interacts with the
hardware device to perform the specified request. If the appropriate device driver for any device,
say a particular model of a printer, is installed on the computer, the user does not need to know
about the device driver, while printing on this printer.
On the basis of their functionality, system software may be broadly divided into two categories
(Figure 6.3) as follows—
5
Figure 6.3 System software
● System software for the management and functionality of computers relates to the
functioning of different components of the computer, like, processor, input and output
devices etc. System software is required for managing the operations performed by the
components of the computer and the devices attached to the computer. It provides
support for various services, as requested by the application software. Operating systems,
device drivers, and system utilities constitute the system software for management of
computers and its resources.
● System software for the development of application software provides services required
for the development and execution of application software. System software provides
the software tools required for the development of application software. The
programming language software, translator software, loader, and linker are also
categorized as system software, and are required for the application software
development.
Operating System
Operating System (OS) is an important part of a computer. OS intermediates between the user of
a computer and the computer hardware. Different kinds of application software use specific
hardware resources of a computer like CPU, I/O devices and memory, as needed by the
application software. OS controls and coordinates the use of hardware among the different
application software and the users. It provides an interface that is convenient for the user to use,
and facilitates efficient operations of the computer system resources. The key functions of OS
are—
7
● It controls the execution of different programs to prevent occurrence of error.
● It provides a convenient interface to the user in the form of commands and
graphical interface, which facilitates the use of computers.
Some available operating systems are Microsoft Disk Operating System (MS-DOS), Windows 7,
Windows XP, Linux, UNIX, and Mac OS X Snow Leopard.
Device Driver
A device driver acts as a translator between the hardware and the software that uses the devices.
In other words, it intermediates between the device and the software, in order to use the device.
Some devices that are commonly connected to the computer are—keyboard, mouse, hard disk,
printer, speakers, microphone, joystick, webcam, scanner, digital camera, and monitor. For
proper working of a device, its corresponding device driver must be installed on the computer.
For example, when we give a command to read data from the hard disk, the command is sent to
the hard disk driver and is translated to a form that the hard disk can understand. The device
driver software is typically supplied by the respective device manufacturers.
Programmers can write the higher-level application code independently of whatever specific
hardware devices it will ultimately use, because code and device can interface in a standard way,
regardless of the software superstructure, or of the underlying hardware. Each version of a
device, such as a printer, requires its own hardware-specific specialized commands. In contrast,
most applications instruct devices (such as a file to a printer) by means of high level generic
commands for the device, such as PRINTLN (print a line). The device-driver accepts these
generic high-level commands and breaks them into a series of low-level, device-specific
commands, as required by the device being driven.
Nowadays, the operating system comes preloaded with some commonly used device drivers, like
the device driver for mouse, webcam, and keyboard. The device drivers of these devices are pre-
installed on the computer, such that the operating system can automatically detect the device
when it is connected to the computer. Such devices are called plug and play devices. In case the
computer does not find the device driver, it prompts the user to insert the media (like a CD which
contains the corresponding device driver) provided along with the device. Most device
manufacturers host the device drivers for their devices on their companies’ websites; users can
download the relevant driver and install it on their computer.
System Utilities
System utility software is required for the maintenance of computers. System utilities are used
for supporting and enhancing the programs and the data in the computer. Some system utilities
may come embedded with the OS and others may be added later on. Some examples of system
utilities are:
9
Figure 6.6 A hard disk having three partitions—C, E, and F
● Backup Utility to make a copy of all information stored on the disk. It also restores
the backed up contents in case of disk failure.
● System Profiling Utility provides detailed information about the software installed on
the computer and the hardware attached to it.
● Network Managers to check the computer network and to log events.
10
Programming Languages
A Programming Language consists of a set of vocabulary and grammatical rules, to express the
computations and tasks that the computer has to perform. Programming languages are used to
write a program, which controls the behavior of computers, codifies the algorithms
precisely, or enables the human-computer interface. Each language has a
unique set of keywords (words that it understands) and a special syntax for
organizing program instructions. The programming language should be
understood, both by the programmer (who is writing the program) and the
computer. A computer understands the language of 0∙s and 1∙s, while the
programmer is more comfortable with English-like language. Programming
Language usually refers to high-level languages like COBOL, BASIC,
FORTRAN, C, C++, Java etc. Programming languages fall into three
categories (Figure 6.8):
● Machine Language is what the computer can understand but it is difficult for the
programmer to understand. Machine languages consist of numbers only. Each kind
of CPU has its own unique machine language.
● Assembly Language falls in between machine language and high-level language. They
are similar to machine language, but easier to program in, because they allow the
programmer to substitute names for numbers.
● High-level Language is easier to understand and use for the programmer but difficult
for the computer.
Regardless of the programming language used, the program needs to be converted into machine
language so that the computer can understand it. In order to do this a program is either
compiled or interpreted.
Figure 6.9 shows the hierarchy of programming languages. The choice of programming language
for writing a program depends on the functionality required from the program and the kind of
program to be written. Machine languages and assembly languages are also called low-level
languages, and are generally used to write the system software. Application software is usually
written in high-level languages. The program written in a programming language is also called
the source code.
11
Figure 6.9 A program in machine language
Machine Language
13
Assembly Language
A program written in assembly language uses symbolic representation of machine codes needed
to program a particular processor (CPU) or processor family. This representation is usually
defined by the CPU manufacturer, and is based on abbreviations (called mnemonics) that help
the programmer remember individual instructions, registers, etc. Small, English-like
representation is used to write the program in assembly language, as shown in Figure 6.11. Some
of the features of a program written in assembly language are as follows:
● Assembly language programs are easier to write than the machine language
programs, since assembly language programs use short, English-like representation
of machine code. For e.g.:
ADD 2, 3
LOAD A
SUB A, B
● The program written in assembly language is the source code, which has to be
converted into machine code, also called object code, using translator software, namely,
assembler.
● Each line of the assembly language program is converted into one or more lines
of machine code. Hence assembly language programs are also machine-
dependent.
● Although assembly language programs use symbolic representation, they are still
difficult to write.
● Assembly language programs are generally written where the efficiency and the speed
of the program are the critical issues, i.e. programs requiring high speed and efficiency.
High-level Language
14
making the process of developing a program simpler and more understandable with respect to
assembly and machine level languages. Some of the features of a program written in high-level
language are as follows:
15
● Programs are easier to write, read or understand in high-level languages than in
machine language or assembly language. For example, a program written in C++ is
easier to understand than a machine language program (Figure 6.12).
● Programs written in high-level languages are the source code which is converted into
the object code (machine code) using translator software like interpreter or compiler.
● A line of code in a high-level program may correspond to more than one line of
machine code.
● Programs written in high-level languages are easily portable from one computer
to another.
Translator Software
Translator software is used to convert a program written in high-level language and assembly
language to a form that the computer can understand. Translator software converts a program
written in assembly language, and high-level language to a machine-level language program
(Figure 6.13). The translated program is called the object code. There are three different kind of
translator software:
16
Figure 6.12 A C++ program
17
Figure 6.13 Translator software
● Assembler,
● Compiler, and
● Interpreter.
Assembler converts a program written in assembly language to machine language. Compiler and
interpreter convert a program written in high-level language to machine language. Let’s now
discuss, briefly, the different kinds of translator software.
Assembler
Compiler
A program written in a high-level language has to be converted to a language that the computer
can understand, i.e. binary form. Compiler is the software that translates the program written in
a high-level language to machine language. The program written in high-level language is
referred to as the source code and compiled program is referred to as the object code. The object
code is the executable code, which can run as a stand-alone code. It does not require the
compiler to be present during execution. Each programming language has its own compiler.
18
Some languages
19
that use a compiler are C++, COBOL, Pascal, and FORTRAN. In some languages, compilation
using the compiler and linking using the linker are required for creating the executable object
code.
The compilation process generally involves two parts—breaking down the source code into
small pieces and creating an intermediate representation, and constructing the object code for
the intermediate representation. The compiler also reports syntax errors, if any, in the source
code.
Interpreter
The purpose of an interpreter is similar to that of a compiler. The interpreter is used to convert
the high-level language program into computer-understandable form. However, the interpreter
functions in a different way than a compiler. Interpreter performs line-by-line execution of the
source code during program execution. Interpreter reads the source code line-by-line, converts
it into machine understandable form, executes the line, and then proceeds to the next line. Some
languages that use an interpreter are BASIC and Python.
Difference Between a Compiler and An Interpreter: Compiler and Interpreter are used to
convert a program written in high-level language to machine language; however, they work
differently. The key differences between a compiler and an interpreter are as follows:
● Interpreter looks at a source code line-by-line. Compiler looks at the entire source code.
● Interpreter converts a line into machine executable form, executes the line, and
proceeds with the next line. Compiler converts the entire source code into object-code
and creates the object code. The object code is then executed by the user.
● For a given source code, once it is compiled, the object code is created. This object
code can be executed multiple times by the user. However, the interpreter executes line-
by-line, so executing the program using an interpreter means that during each
execution, the source code is first interpreted and then executed.
● During execution of an object code, the compiler is not required. However, for
interpretation, both interpreter and the source code is required during execution
(because source code is interpreted during execution).
● Since the interpreter interprets line-by-line, the interpreted code runs slower
than the compiled code.
Linker
Linker is a program that links several object modules and libraries to a single executable
program. A source code of a program is often very large consisting of several hundred or more
lines. The source code may also include reference to libraries. All these independent modules
may not be stored in a single object file. The code is broken down into many independent
modules for easy debugging and maintenance. Before execution of the program, these modules
and the required libraries are linked together using the linker software. The compiled and the
linked program are called the executable code.
20
Loader
The loader software is used to load and re-locate the executable program in the main memory.
Software has to be loaded into the main memory during execution. Loader assigns storage space
to the program in the main memory for execution. Figure 6.15 shows the working of a Java
Runtime Environment (JRE). The java source file Sample.java is compiled and converted into a
set of bytecodes and are stored in Sample.class file. At runtime, the class loader loads the
bytecodes from the hard disk, checks it, and runs it in an interpreter. The interpreter executes
the bytecode and makes calls to the underlying hardware.
The hierarchy of program execution from writing the program to its execution is shown in Figure
6.16.
21
APPLICATION SOFTWARE
The software that a user uses for accomplishing a specific task is the application software.
Application software may be a single program or a set of programs. A set of programs that are
written for a specific purpose and provide the required functionality is called software package.
Application software is written for different kinds of applications—graphics, word processors,
media players, database applications, telecommunication, accounting purposes etc.
● Word Processing Software: For writing letters, reports, documents etc. (e.g. MS-WORD).
● Spreadsheet Software: Used for creating budget, tables etc. (e.g. MS-Excel).
● Presentation Software: To make presentations, slide shows (e.g. MS-PowerPoint)
● Suite of Software having Word Processor, Spreadsheet and Presentation Software: Some
examples are MS-Office, Google Docs, Sun Openoffice, Apple iWork.
● CAD/CAM Software: To assist in architectural design. (e.g. AutoCAD, Autodesk)
23
Different kinds of software are made available for use to users in different ways. The user may
have to purchase the software, can download for free from the Internet, or can get it bundled
along with the hardware. Nowadays with the advent of Cloud computing, many application
software are also available on the cloud for use through the Internet, e.g. Google Docs. The
different ways in which the software are made available to users are:
● Retail Software is off-the-shelf software sold in retail stores. It comes with printed
manuals and installation instructions. For example, Microsoft Windows operating
system.
● OEM Software stands for “Original Equipment Manufacturer” software. It refers to
software which is sold, and bundled with hardware. Microsoft sells its operating system
as OEM software to hardware dealers. OEM software is sold at reduced price, without
the manuals, packaging and installation instructions. For example, Dell computers are
sold with the “Windows 7” OS preloaded on them.
● Demo Software is designed to demonstrate what a purchased version of the software
is capable of doing and provides a restricted set of features. To use the software, the
user must buy a fully- functional version.
● Shareware is a program that the user is allowed to try for free, for a specified period of
time, as defined in the license. It is downloadable from the Internet. When the trial
period ends, the software must be purchased or uninstalled.
● Freeware is software that is free for personal use. It is downloadable from the
Internet. The commercial use of this software may require a paid license. The author
of the freeware software is the owner of the software, though others may use it for
free. The users abide by the license terms, where the user cannot make changes to it,
or sell it to someone else.
● Public Domain Software is free software. Unlike freeware, public domain software
does not have a copyright owner or license restrictions. The source code is publicly
available for anyone to use. Public domain software can be modified by the user.
● Open-Source Software is software whose source code is available and can be
customized and altered within the specified guidelines laid down by the creator.
Unlike public domain software, open-source software has restrictions on their use and
modification, redistribution limitations, and copyrights. Linux, Apache, Firefox,
OpenOffice are some examples of open-source software.
SUMMARY
24
hardware. It manages resources of the computer system, controls execution of
programs, and provides a convenient interface to the user for use of the computer.
● MS-DOS, Windows XP, Windows 7, UNIX and Mac OS X, are some examples of OS.
25
● Device driver intermediates between the device and the software that uses the device.
Each device has its own device driver, which must be installed on the computer for
the proper working of the device. Device drivers can be character or block device
drivers.
● For plug and play devices, the device drivers come preloaded with the operating system.
● Compiler translates the program written in a high- level language to machine language.
The high-level language program is the source code, and the compiled program is the
object code.
● Interpreter converts the high-level language program into machine code, but
performs line-by-line execution of the source code, during the program execution.
● Linker links several object modules and libraries to a single executable program.
● Loader loads and re-locates the executable program in the main memory.
● Application software is a single program or a set of programs that perform a specific
task. Word processing software, image processing software, geographical information
systems, accounting software, spreadsheet, presentation software, and web browser
software are examples of application software.
● Software acquisition may require the user to purchase the software like retail software,
or use free software like freeware, public-domain software, and open- source software.
26
KEYWORDS
27
Character device driver Loader Spreadsheet
software
Compiler Low-level language System profiling
Cryptographic utility Machine language System software
Data compression utility Network managers System utility
Demo software Object code Translator software
Device driver OEM software Web browser
software
Disk cleaners Open-source software Word processing
Disk compression Operating system software
Disk partitioning Plug and play devices
Executable code Presentation Software
QUESTIONS
Section 6.1–6.3
Section 6.3.1–6.3.3
8. “OS controls and coordinates the use of hardware among the different application software
and the users”. Explain.
28
13. Where is the device driver of the plug and play device located on the computer?
29
14. What is the purpose of a device driver?
15. What are character device drivers and block device drivers?
19. List any five system utilities and also list the purpose of each.
20. Explain the purpose of the following system utilities in one line—(i) Anti-virus, (ii) Data
compression, (iii) Cryptographic, (iv) Disk compression, (v) Disk partitioning, (vi) Disk
cleaners, (vii) Backup utility, (viii) System Profiling utility, (ix) Network managers.
Section 6.3.4–6.3.4.4
33. Why is it easier to write a program in a high-level language than an assembly language?
30
35. COBOL and C are generation languages.
Section 6.3.5–6.3.7
41. Name two high-level languages that use a compiler for translation.
42. Name two high-level languages that use interpreters for translation.
45. Draw the cycle from the writing of the program in a high-level language to its execution.
Section 6.4
48. Explain the purpose of the following application software in one line—(i) Word processing
software, (ii) Image processing software, (iii) Accounting software, (iv)Spreadsheet software,
(v) Presentation software, (vi) Web browser software, and (vii) Geographical Information
Systems.
49. Give an example each of the following application software—(i) Word processing software,
(ii) Image processing software, (iii) Accounting software, (iv) Spreadsheet software, (v)
Presentation software, (vi) Web browser software, and (vii) Geographical Information
Systems.
Extra Questions
1. OS
2. MS-DOS
31
52. Write short notes on:
1. System software
2. Operating System
3. Device driver
4. System utilities
5. Programming Language
6. Machine language
7. Assembly language
8. High-level languages
9. Generation ofProgramming Languages
10. Translator software
11. Assembler
12. Compiler
13. Interpreter
14. Linker and Loader
15. Application Software
7
OPERATING SYSTEM
Contents
● Objectives of OS
● Types of OS—Single user and single task, single user and multitasking, multi
user, multiprocessing, real time, embedded OS
● Functions of OS—Process management, memory management, file management,
device management, protection and security, user interface
● Process management
32
Process—Process states (new, ready, running, waiting, terminated)
CPU scheduling—Scheduler, scheduling algorithms (FCFS, SJF, RR)
● Deadlock—Deadlock conditions, deadlock prevention, deadlock avoidance
● Memory management
Memory allocation—Multiple partition allocation, paging
Virtual memory—Demand paging
● File management—Files, directory structure
● Device management—Device drivers, I/O scheduling, buffering, spooling
● Protection and security
● User interface—CLI, GUI
● Examples of operating systems—MS-DOS, Windows family of OS, Linux
Any computer system you use has an operating system. The user interacts with the machine via
the operating system. A software on the machine interacts with the hardware via the operating
system. Operating systems intermediates between the hardware and the user. The purpose of this
chapter is to introduce you to the Operating System.
INTRODUCTION
The computer system comprises a functional set of hardware, software, user and data. Hardware
consists of the components of a computer like memory, processor, storage devices, and
Input/Output devices. The software may be of different kinds—application software and system
software. A computer system may be a single stand-alone system or may consist of several
interconnected systems. The user uses the application software to perform various tasks, for
example, the user uses word processing software for document preparation. While using the
application software, the user uses the storage of a computer—to store a document on the hard
disk, to execute a command on the CPU, to retrieve a document from a peripheral device or to
print documents on a printer. For using the hardware, there is a need for software that interacts
with both the hardware and the application software. Operating system (OS) is the software that
provides an interface between the computer hardware, and the application programs or users
(Figure 7.1).
In this chapter, we discuss the components of the operating system, the different types of
operating system and the functions of the operating system. A brief description of some
operating systems is also given.
33
Figure 7.1 View of components of computer system
34
Operating system is system software that controls and coordinates the use of hardware among
the different application software and users. OS intermediates between the user of the computer
and the computer hardware. The user gives a command and the OS translates the command into
a form that the machine can understand and execute. OS has two main objectives—(1) to make
the computer system convenient and easy to use, for the user, and—(2) to use the computer
hardware in an efficient way, by handling the details of the operations of the hardware.
● The OS hides the working of the hardware from the user and makes it
convenient for the user to use the machine. The application program
used by the user requires the use of the hardware during processing.
Some examples are—display of application∙s user interface, loading a
program into memory, using I/O devices, allocating CPU to different
processes during execution, and storing or loading data from a hard disk. When
using the machine, the user gives the command to perform the required actions to the OS
and the OS handles all the operational steps. The user is not bothered about how these
actions will be performed. This is the job of the OS. OS provides an interface to the
application programs to interact with the hardware. The user need not get into the details
of this interaction.
● At the other end, the different resources of computer hardware have to be managed and
controlled. This includes managing the communication between different devices,
controlling the sequence and execution of processes, allocating space on the hard disk,
providing error handling procedures etc. OS supervises and manages the hardware of
the computer.
Some of the commonly used operating systems are Microsoft Disk Operating System (MS-
DOS), Windows 7, Windows XP, Linux, UNIX, and Mac OS X Snow Leopard.
TYPES OF OS
ROSes are classified into different types depending on their capability of processing—(1)
Single user, (2) Multi User, (3) Multitasking, (4) Multiprocessing, (5) Real time, and (6)
Embedded.
● Single User and Single Task OS is for use by a single user for a standalone single
computer for performing a single task (Figure 7.2). Operating systems for Personal
Computers (PC) are single user OS. For example, if the user is editing a document, then a
document cannot be printed on the printer simultaneously. Single user OS are simple
operating systems designed to manage one task at a time. MS-DOS is an example of a
single user OS.
35
Figure 7.2 A single user performing a single task
● Single User and Multitasking OS allows execution of more than one task or process
concurrently. For this, the processor time is divided amongst different tasks. This
Division of time is also called time sharing. The processor switches rapidly between
processes. For example, the user can listen to music on the computer while writing an
article using a word processor software. The user can switch between the applications
and also transfer data between them (Figure 7.3). Windows 95 and all later versions of
Windows are examples of multitasking OS.
Figure 7.3 A single user performing multitasking (issuing print command and making
drawings)
● Multi User OS is used in computer networks that allow the same data and applications
to be accessed by multiple users at the same time (Figure 7.4). The users can also
communicate with each other. Linux, UNIX, and Windows 7 are examples of multi user
OS.
● Multiprocessing OS have two or more processors for a single running process.
36
Processing takes place in parallel and is also called parallel processing. Each
processor
37
works on different parts of the same task, or, on two or more different tasks. Since
execution takes place in parallel, they are used for high speed execution, and to increase
the power of computers. Linux, UNIX and Windows 7 are examples of multiprocessing
OS.
FUNCTIONS OF OS
Operating system is a large and complex software consisting of several components. Each
component of the operating system has its own set of defined inputs and outputs. Different
components of OS perform specific tasks to provide the overall functionality of the operating
system (Figure 7.5). Main functions of the operating system are as follows:
38
Figure 7.5 Functions of OS
PROCESS MANAGEMENT
39
● A process is a program in a state of execution. It is a unit of work for the operating
system. A process can be created, executed, and stopped. In contrast, a program is
always
40
static and does not have any state. A program may have two or more processes running.
A process and a program are, thus, two different entities.
● To accomplish a task, a process needs to have access to different system resources like
I/O devices, CPU, memory etc. The process management function of an operating
system handles allocation of resources to the processes in an efficient manner. The
allocation of resources required by a process is made during process creation and process
execution.
● A process changes its state as it is executed. The various states that a process
changes during execution are as follows (Figure 7.6):
The concurrent execution of the process requires process synchronization and CPU scheduling.
The CPU scheduling, process synchronization, communication, and deadlock situations are
described in the following subsections.
CPU Scheduling
● CPU or processor is one of the primary computer resources. All computer resources
like I/O, memory, and CPU are scheduled for use.
● CPU scheduling is important for the operating system. In a multiprogramming and time
sharing system, the processor executes multiple processes by switching the CPU among
the processes, so that no user has to wait for long for a program to execute. To enable
running of several concurrent processes, the processor time has to be distributed
amongst all the processes efficiently.
● Scheduler is a component of the operating system that is responsible for scheduling
41
transition of processes. At any one time, only one process can be in running state and
the rest are in ready or waiting state. The scheduler assigns the processor to different
processes in a manner so that no one process is kept waiting for long.
42
● Scheduling can be non-pre-emptive scheduling or preemptive scheduling. In non-pre-
emptive scheduling, the processor executes a process till termination without any
interruption. Hence the system resources are not used efficiently. In preemptive
scheduling, a running process may be interrupted by another process that needs to
execute. Pre-emption allows the operating system to interrupt the executing task and
handle any important task that requires immediate action. In preemptive scheduling, the
system resources are used efficiently.
● There are many different CPU scheduling algorithms that are used to schedule
the processes. Some of the common CPU scheduling algorithms are as follows—
o First Come First Served (FCFS) Scheduling: As the name says, the process
that requests for the CPU first, gets the CPU first. A queue is maintained for the
processes requesting the CPU. The process first in the queue is allocated the CPU
first. FCFS scheduling is non-pre-emptive. The drawback of this scheduling
algorithm is that the process that is assigned to the CPU may take a long time to
complete, keeping all other processes waiting in the queue, even if they require
less CPU time.
o Shortest Job First (SJF) Scheduling: The process that requires the least CPU
time is allocated the CPU first. SJF scheduling is non-pre-emptive. The
drawback of this scheduling is that a process that requires more CPU time may
have to wait for a long time, since processes requiring less CPU time will be
assigned the CPU first.
o Round Robin (RR) Scheduling: It is designed for time-sharing systems. RR
scheduling is preemptive. In this scheduling, a small quantum of time (10—100
ms) is defined, and each process in the queue is assigned the CPU for this
quantum of time circularly. New processes are added at the tail of the queue and
the process that has finished execution is removed from the queue. RR
scheduling overcomes the disadvantage of FCFS and SJF scheduling. A process
does not have to wait for long, if it is not the first one in the queue, or, if it
requires CPU for a long period of time.
Figure 7.7 shows the ready queue—P#1 with CPU time requirement of 5 units, P#2 with 7 units
and P#3 with 4 units, are scheduled, using the different CPU scheduling algorithms.
Process Synchronization
● In a computer, multiple processes are executing at the same time. The processes that
share the resources have to communicate with one another to prevent a situation
where one process disrupts another process.
43
Figure 7.7 Illustrating CPU scheduling algorithms with an example
● When two or more processes execute at the same time, independent of each other,
they are called concurrent processes.
● A situation where multiple processes access and manipulate the same data concurrently,
in which the final result depends on the order of process execution, is called a race
condition. To handle such situations, synchronization and coordination of the processes
is required.
Deadlock
o Mutual Exclusion—Only one process at a time can use the resource. Any
other process requesting the resource has to wait until the resource is released.
44
No Pre-emption—A process releases the resource by itself. A process
o
cannot remove the resource from another process.
o Hold and Wait—A process holds a resource while requesting another
resource, which may be currently held by another process.
o Circular Wait—In this situation, a process P1 waits for a resource held by
another process P2, and the process P2 waits for a resource held by process
P1.
● Deadlock handling can be done by deadlock avoidance and deadlock prevention.
o Deadlock Prevention is a set of methods that ensures that at least one of the
above four necessary conditions required for deadlock does not hold true.
o Deadlock Avoidance requires that the operating system be given information in
advance regarding the resources a process will request and use. This information
is used by the operating system to schedule the allocation of resources so that no
process waits for a resource.
MEMORY MANAGEMENT
In a computer, there may be multiple processes executing at the same time. Every process that
needs to execute, requires a certain amount of memory. Memory management is one of the tasks
handled by the operating system. Memory management schemes handle the allocation of
memory to different processes. On completion of process execution, the memory is deallocated
and made available to another process. Additionally, different processes that have been allocated
memory should not interfere with each other∙s memory space. This requires some
memory protection and sharing mechanism. Now we will discuss memory
allocation, de-allocation, re- allocation of free memory, and memory
protection and sharing.
Memory Allocation
● In single-user and single-task operating systems like MS-DOS, only one process can
execute at a time. After the termination of the process, the allocated memory is freed
and is made available to any other process.
● In a multiprogramming system, in addition to allocation and deallocation of memory,
more tasks are involved like keeping track of processes allocated to the memory,
memory protection and sharing etc.
● There are different memory allocation schemes to allocate memory to the processes
that reside in memory at the same time. The different memory allocation schemes are
as follows:
o Multiple Partition Allocation—The operating system keeps track of blocks of
memory which are free and those which are unavailable. The single block of
available memory is called a hole. When a process requires memory, a hole
large enough for the process is allocated. As different processes release the
memory, the released block of memory is placed in the set of holes. During
allocation of memory, the set of holes is searched to determine which hole is to
be allocated. For this, three hole allocation strategies are used—(1) first-fit
(allocate the first hole that is big enough for the process, (2) best-fit (allocate the
45
smallest hole that is big enough for the process, and (3) worst-fit (allocate the
largest available hole). Memory allocated using any of these strategies results in
fragmentation. When the processes are allocated memory and removed from
memory, the free
46
memory is broken into small pieces. These small pieces of fragmented memory
lie unused. Paging scheme is used to overcome fragmentation. Figure 7.9 shows
allocation of memory to a process requiring 8 KB of memory, using the first fit,
best fit, and worst fit allocation strategies.
o Paging—In paging, the physical memory is broken into fixed size blocks called
frames. This is the primary memory allocated to the process. The logical memory
is broken into blocks of the same size called pages. Generally pages are of sizes
varying from 1 KB to 8 KB. When a process is executed, its pages are loaded
into the frames.
An address generated by the CPU has two parts—page number and page
offset. A page table is maintained by the operating system that maps the page
number to the frame number. The page number is used to index the page table
and get the frame number. The page offset is added to the page frame number
to get the physical memory address (Figure 7.10).
47
Paging handles the problem of fragmentation. The frames need not be contiguous
and can reside anywhere in the memory. A process can allocate memory from
holes created by fragmentation, which may be anywhere in the memory.
Virtual Memory
● In the memory management schemes discussed in the previous section, the whole
process is kept in memory before the execution starts. However, for some applications,
large memory is required to run the applications, and the whole program cannot be
loaded into the memory.
● Virtual memory allows the execution of those processes that are not completely
in memory.
● Virtual memory is commonly implemented by demand paging. Demand paging is similar
to paging with swapping. Swapping is transferring a block of data from the on-line
secondary storage like hard disk to the memory and vice versa.
● In demand paging, the processes reside in the online secondary memory. When a
process executes and a page is required, that page is swapped-in into the memory
(Figure 7.11). This allows execution of large-sized programs without loading them
completely into the memory.
FILE MANAGEMENT
● The file management function of the operating system involves handling the file
system which consists of two parts—a set of files, and a directory structure.
● File is a collection of related information, has a name, and is stored on a secondary
storage. It is the smallest named unit that can be written to a secondary storage device.
Data cannot be stored on the secondary storage if it is not in the form of a file. A file
has attributes like its name, location, size, type, time, and date of creation etc. (Figure
7.12). The information stored in a file can be accessed in different ways—sequential
access (access is in a sequential order from start to end) and direct access (the file can
be accessed in any order).
48
Figure 7.12 Showing the file attributes
● Directory structure provides information about the files stored on the secondary storage.
Directory contains information about all the files within it. The information about the
files is kept as entries in the directory of the device. A directory further may have a sub-
directory defined within it. Directory contains the name, location, size, and type of all
the files defined on the device. The tree-structured directory (Figure 7.13) is the
commonly used directory structure.
● The operating system manages the storage media like the disk and implements the
abstract concept of the file. System calls are an interface between the process and the
operating system. Operating system provides system calls for creating, reading,
writing, deleting, repositioning, and truncating a file. Some of the operations that can
be performed on a directory are—search for a file, create, delete and rename a file, list
a directory, and traverse the file system within the directory. The user simply uses the
system calls like “dir”, “list” to perform operations on a file or directory, without going
into the details of its working.
49
DEVICE MANAGEMENT
● Several peripheral devices like mouse, hard disk, printer, plotter etc. are connected to
the computer. The peripheral devices have varying characteristics like character or
block device, sequential or random access device, and dedicated or shared device.
● OS manages and controls the devices attached to the computer. OS provides
appropriate functionality to the application programs for controlling different aspects of
the devices. Figure 7.14 shows the device manager and system properties in Windows
XP Professional.
● OS handles the devices by combining both hardware and software techniques. The
I/O hardware includes the ports, buses, and device controllers for the devices. The OS
communicates with the I/O hardware via the device driver software. The device
driver software comes along with each device.
● A device communicates with the computer hardware via a port (for
example, a serial port or a parallel port). Bus is a common set of wires
used by one or more devices. The computer uses different kinds of
buses like PCI bus for connecting processor or memory to the fast
devices, expansion bus to connect to slow I/O devices and SCSI bus to
connect disks. A device controller operates a port, bus, and a device.
Device controller is just like a bridge between the device and the
operating system. The device controller receives the data from a
connected device, stores it temporarily, and then communicates the
data to the device∙s device driver. Device driver is the software with
which the device controller communicates with the operating system
(Figure 7.15).
50
Figure 7.15 Devices interacting with OS
● Operating systems enable handling of the different I/O devices in a uniform way. The
complexity of handling the different devices is abstracted and hidden in the device
drivers of the devices. The device drivers hide the differences among the different
device controllers and present a uniform interface to the operating system.
● In addition to managing the peripheral devices, OS also provides various services
related to I/O like I/O scheduling, buffering, spooling, and error handling.
● Scheduling of I/O requests involves ordering the requests to improve performance of the
system and provide fair access to all processes. For this, a queue of requests is
maintained for each device. The I/O scheduler re-arranges the queue to improve the
efficiency of the overall system.
● Buffer is a memory area that stores the data, while it is being transferred between two
devices or between a device and an application. The speed at which the I/O device can
transfer data is different from the speed at which the data is processed. Buffering
handles the speed mismatch by storing the data in a buffer till the complete data has
arrived and then writing it in a single write operation.
● Spool (Simultaneous Peripheral Operation On-Line) is a buffer in memory area or disk.
Spooling stores the jobs in a spool where the device can access it when it is ready.
Spooling is commonly used for printers. Users may give several print commands, and
continue working with other operations. However, the printer can print only one job at
a time. The rest of the jobs are stored in the spool in a queue, and the printer accesses
the spool when it is ready to print the next job.
● The access of programs, processes, and users, to the resources defined by the
computer are controlled by the protection mechanism.
51
● Protection ensures that the resources of the computer are used in a consistent way.
52
● Security mechanism prevents unauthorized access to the computer. Security concerns
include— security of software, security of data stored in the computer, and security of
physical resources of the computer.
● In a personal computer, security can be ensured using—(1) user accounts—individual
accounts for each user, (2) user authentication—using password protection (Figure
7.16),
(3) access rights—define rights for access of different kinds of information for different
people, (4) data encryption—store data in computers in encrypted form, and (5) data
backup—storing data on a peripheral device other than the hard disk. In a networked
environment, only trusted computers should be able to share data. Some of the common
security threats occur due to hacking, viruses etc.
Figure 7.16 Create password and manage user account in Windows XP Professional
USER INTERFACE
● The primary goal of an operating system is to make the computer convenient for use by
its user. It should allow users to easily access and communicate with the applications and
the hardware.
● The users can interact with the computer by using mainly two kinds of interfaces—
(1) Command Line Interface (CLI), and (2) Graphical User Interface (GUI).
● CLI requires the user to interact with the operating system in the form of text keyed in
from the keyboard. In this, the user has to learn and remember the different commands
required for copying, deleting, opening a file or folder etc. (Figure 7.17). MS-DOS and
Linux shell are examples of command line mode of interfaces.
53
Figure 7.17 Command line interface
● The GUI uses graphics to display the various commands. The interface consists of icons,
menus, windows, and pointers. The user need not learn the commands, instead, the user
can give instructions by moving the pointer on the screen using a mouse and pressing
the mouse button (Figure 7.18). MS“Windows 7 MS” and MS“Mac OS 10 MS” are
examples of graphical mode of interface. GUI interfaces for the Linux OS also exist like
the GNU Object Model Environment (GNOME).
MS-DOS, Windows family of operating systems, Unix OS, Linux OS, and Mac OS X are some
examples of commonly used OSs. Each operating system has specific characteristics. Here, we
will discuss the features of the MS-DOS, Windows family of operating systems and Linux
operating system.
54
MS-DOS
● MS-DOS was the first widely-installed operating system for PCs in the 1980s.
● MS-DOS is easy to load and install. It neither requires much memory for the
operating system, nor a very powerful computer to run on.
● MS-DOS is a command line user interface operating system. This means that the user
has to type single line commands through the command interface. So, the user has to
remember the different commands and their syntax.
● It is a single-user and single-tasking operating system for the PC. Only one user can use
it and only one task can be executed, at a given point of time. Also, it does not have built-
in support for networking.
● MS-DOS is a 16-bit OS, meaning thereby that it can send or receive 16 bits of data at
a time and can process 16 bits of data. It is not able to take the advantage of 32-bit
processors.
● To use MS-DOS, users must know where the programs and data are stored and how
to interact with it. In the MS-DOS command mode, command.com routine interprets
the typed in command from the keyboard.
cmd.exe or command prompt is the command line interpreter on the current Windows-based OS.
It is similar to command.com in MS-DOS. cmd.exe is a Windows program that acts as a DOS-
like command line interpreter.
Windows Family of OS
56
Figure 7.19 Windows task manager
The Windows OS has evolved from Windows 1.0 in 1985 to Windows 7 in 2009. In this span of
24 years, several versions of the Windows OS have been released. Table 7.1 gives an overview
of the history of the Windows OS, along with their significance.
Year Windows OS Comments
Released
1985 Windows 1.0 It was not successful
1990 Windows 3.0 The first commercially successful version of Windows. It is an
upgrade to the interface over Windows 1 and 2
1993 Windows NT 3.1 The first Microsoft OS not based in DOS. Separate versions of NT with
their DOS counterparts are released
1995 Windows 95 The first native 32 bit OS. Microsoft plans to merge the NT and
DOS platforms but are unsuccessful due to backward compatibility
issues and lack of hardware support for NT.
1998 Windows 98 Microsoft integrates its web browser in the GUI and file
manager. Hackers can use the Internet to infiltrate a computer or
network.
2000 Windows 2000 As with Windows 95, Microsoft planned Windows 2000 to merge the
NT and DOS based OS but was unsuccessful
2001 Windows XP Windows XP successfully merges the compatibility found in Windows
98 with the stability found in Windows NT/2000. It provides enhanced
stability over Windows 98.
2005 Windows XP Professional x64 Edition OS was slow to take off due to the dearth of 64-bit
software and drivers
2008 Windows Vista First 3D operating system
2009 Windows 7 Some of the new features included in Windows 7 are advancements
in touch, speech, and handwriting recognition, support for virtual hard
57
disks, support for additional file formats, improved performance
on multi-core processors, improved boot performance, and kernel
improvements.
Linux OS
● Linux is a Unix-like OS. Unix OS has a user interface called shell. The kernel
provides an interface for the programs to interact with the hardware, and provides
services like process management and memory management. The shell interacts with
the kernel through the system calls.
● Linux was developed by Linus Torvalds in 1992. Linux is a copyright under the GNU
Public License. Linux is a “free” operating system that is easily available. Since
Linux follows the open development model, it is being constantly upgraded by
programmers across the globe.
● Some organizations offer Linux with add-on features and capabilities. Red
Hat, Mandrake, Debian and Novell are the popular vendors of Linux OS.
● Tux, the Linux penguin is the official mascot of Linux.
● Linux is a command line user interface OS. Linux has GUI interfaces called desktop
environments like GNOME and K Desktop Environment (KDE). The GUI interface
is convenient for the user to use.
● Linux is a 32-bit, multi-tasking OS. It supports multiple users and multiple processors.
● Linux is a reliable and secure OS, and is available almost for free. So, Linux is
fast becoming a very popular and powerful OS.
● Linux OS is easily available, such as Redhat Linux ver. 9, and Debian∙s—
Ubuntu, Kubuntu, and Edubuntu.
SUMMARY
● Operating systems intermediates between the computer hardware and the computer user.
● The objective of an OS is to make the computer system convenient for the user to use,
and to use the computer hardware efficiently.
● Types of OS—Single user and single task OS is for use by a single user for a single
task. Multitasking OS allows execution of more than one task concurrently. Multi User
OS allows concurrent access of the same data and applications by multiple users.
Multiprocessing OS have two or more processors for a single running process, which
execute in parallel. Real time OS responds to an event within a predetermined time.
Embedded OS is embedded in appliances like microwaves and washing machines.
● Functions of OS are process management, memory management, file
management, device management, protection and security, and user interface.
58
● Process management includes handling the scheduling of processes,
process synchronization and communication, and deadlock situations.
● A process is a program in a state of execution. During execution, a process can be in
a new, ready, running, waiting or terminated state.
59
● CPU scheduler assigns the processor to different processes so that no process is
kept waiting for long. Scheduling can be non-pre-emptive scheduling and
preemptive scheduling.
● FCFS, SJF and RR are CPU scheduling algorithms. In FCFS, the process that requests
the CPU first gets the CPU first. In SJF, the process that requires the least CPU time is
allocated the CPU first. In RR scheduling, each process in the queue gets CPU for a
quantum of time circularly.
● Process synchronization is required when multiple processes access and manipulate
the same data, concurrently.
● A deadlock arises when the four necessary condi- tions—mutual exclusion, no
preemption, hold and wait, and circular wait, hold true simultaneously in a
system.
● Memory management includes memory allocation, de-allocation, re-allocation of
free blocks, and memory protection and sharing.
● Virtual memory is implemented by demand paging, which is paging with swapping.
● The file manager handles the file system consisting of a set of files and a
directory structure. OS provides system calls for performing operations on the
file.
● OS handles the devices using a combination of hardware and software techniques. The
I/O hardware includes the ports, buses and device controllers for the devices. OS
interacts with I/O hardware via the device driver software of the device.
● Spooling stores the jobs in a spool (a buffer in memory area or disk) where the device
can access it when it is ready.
● Protection ensures that the resources of computers are used in a consistent way.
Security mechanism prevents unauthorized access to a system.
● CLI and GUI are the two kinds of user interfaces.
● MS-DOS, Windows XP, UNIX, Linux, and Mac OS X are some examples of OSs.
KEYWORDS
61
Hole Parallel processing Tree-structured
directory
I/O scheduling Preemptive scheduling UNIX
Linux Process User Interface
Mac OS X Process Management Virtual memory
Memory allocation Process states Window XP
Memory Management Process
Synchronization
MicroSoft Disk Operating System Protection and Security
(MS-DOS) Race condition
QUESTIONS
Section 7.1–7.3
2. “OS makes it convenient for the user to use the machine”. Explain.
14. Give an example of each of the following types of OS: (i) Single user and Single
Task, (ii) Single user and Multitasking, (iii) Multi User, (iv) Multiprocessing, and (v) Real
time.
62
Section 7.4
63
15. List the main function of the OS.
17. List the activities handled by each of the following functions of the OS (i) Process
Management, (ii) Memory Management, (iii) File Management, (iv) Device Management,
(v) Protection and Security, and (vi) User Interface.
Section 7.5–7.5.4
24. Explain the working of (i) FCFS, (ii) SJF, and (iii) RR scheduling algorithms.
27. How does the RR algorithm overcome the drawbacks of FCFS and SJF?
35. Explain the following in context of the deadlock: (i) Mutual Exclusion, (ii) No preemption,
(iii) Hold and Wait, and (iv) Circular wait.
64
Section 7.6–7.6.2
Section 7.7–7.8
65
57. Name a spooled device.
Section 7.9
60. Name a few techniques used for ensuring security of a stand-alone computer.
62. Give one example of each OS using CLI and GUI interfaces.
65. Write short notes on MS-DOS, Windows family of OS, and Linux OS.
Extra Questions
1. MS-DOS
2. FCFS
3. SJF
4. RR
5. CLI
6. GUI
7. GNOME
8. KDE
9. SPOOL
1. Objectives of OS
2. Types of OS
3. Functions of OS
4. Process Management
5. Process
6. CPU Scheduling
7. Scheduling algorithms
8. Process Synchronization
66
9. Deadlock
10. Memory Management
11. Memory allocation
12. Memory Fragmentation
13. Paging
14. Demand paging
15. File Management
16. Device Management
17. Device drivers
18. Protection and Security
19. User Interface
20. MS-DOS
21. Windows family of OS
22. Linux OS
67
68