MCS-203 Operating Systems
MCS-203 Operating Systems
MCS-203 Operating Systems
Operating Systems
Indira Gandhi National Open University
School of Computer and Information
Sciences (SOCIS)
UT/OUTP SECURITY
INP AGEMEUT
M AN NT
Block Title 1
MCS-203
Operating Systems
Indira Gandhi
National Open University
School of Computer and
Information Sciences
Block
1
INTRODUCTION TO OPERATING SYSTEMS
AND PROCESS MANAGEMENT
UNIT 1
Operating System: An Overview 7
UNIT 2
Processes 29
UNIT 3
Interprocess Communication and Synchronization 57
UNIT 4
Deadlocks 81
PROGRAMME/COURSE DESIGN COMMITTEE
Prof. Sanjeev K. Aggarwal, IIT, Kanpur Shri Sanjeev Thakur
Shri Navneet Aggarwal Amity School of Computer Sciences, Noida
Trinity BPM, New Delhi Shri Amrit Nath Thulal
Prof. M. Balakrishnan, IIT, Delhi Amity School of Engineering and Technology
Prof. Pandurangan, C., IIT, Madras New Delhi
Ms. Bhoomi Gupta Dr. Om Vikas(Retd), Ex-Sr. Director,
Sirifort College of Computer and Technology Ministry of ICT, Delhi
Management, New Delhi Shri Vishwakarma
Shri Manoj Kumar Gupta Amity School of Engineering and Technology
Keane India Ltd., New Delhi New Delhi
Shri Sachin Gupta Prof (Retd) S. K. Gupta, IIT Delhi
Delhi Institute of Advanced Studies, Prof. T.V. Vijaya Kumar, Dean, SC&SS,
New Delhi JNU, New Delhi
Prof. Harish Karnick, IIT, Kanpur Prof. Ela Kumar, Dean, CSE, IGDTUW, Delhi
Shri Anil Kumar Prof. Gayatri Dhingra, GVMITM, Sonipat
Amity School of Engineering and Technology
New Delhi Sh. Milind Mahajani Vice President,
Impressico Business Solutions, Noida, UP
Dr. Kapil Kumar, IIMT, Meerut
D r . Sachin Kumar, Prof. V. V. Subrahmanyam, Director
SOCIS, New Delhi
CCS University, Meerut
Prof. P. V. Suresh,
Ms. Manjulata
Amity School of Engineering and Technology SOCIS, IGNOU, New Delhi
New Delhi Dr. Shashi Bhushan
Shri Ajay Rana SOCIS, IGNOU, New Delhi
Amity School of Computer Sciences, Noida Shri Akshay Kumar, Associate Prof.
Dr. Divya Sharma SOCIS, IGNOU, New Delhi
Bharati College, Delhi Shri M. P. Mishra, Associate Prof.
Shri Neeraj Sharma SOCIS, IGNOU, New Delhi
Havard Institute of Management Technology Dr. Sudhansh Sharma, Asst. Prof
Noida SOCIS, IGNOU, New Delhi
PRINT PRODUCTION
Mr. Tilak Raj Mr. Yashpal
Asst. Registrar (Pub.) Section Officer (Pub.)
MPDD, IGNOU, New Delhi MPDD, IGNOU, New Delhi
March, 2021
© Indira Gandhi National Open University, 2021
All rights reserved. No part of this work may be reproduced in any form, by mimeograph or any other
means, without permission in writing from the Indira Gandhi National Open University.
Further information on the Indira Gandhi National Open University courses may be obtained from the
University’s office at Maidan Garhi, New Delhi-110068.
Printed and published on behalf of the Indira Gandhi National Open University, New Delhi by the
MPDD, IGNOU, New Delhi
Laser Typesetting : Akashdeep Printers, 20-Ansari Road, Daryaganj, New Delhi-110002
COURSE INTRODUCTION
The most fundamental of all system programs is the operating system, which controls
computer’s resources and provides the base on which application programs may be
written. A modern operating system manages one or more processors, processes,
files, a hierarchy of memory, clocks, disks, network interfaces, I/O devices, protection
and security. The operating system’s purpose is to provide an orderly and controlled
allocation of all of these resources among the programs competing for them.
This is a core course on Operating Systems covering the broader perspective of its
operation. Each unit includes presentation of the contents with examples and solved
problems. This course introduces the key mechanisms of the operating system like
process management, memory management, file systems, I/O management and
protection and security. The whole course is organised into 4 Blocks.
Block 1 covers the Introduction to Operating Systems, the role of processes, their
creation, process scheduling, interprocess communication and synchronization and
deadlocks.
Block 2 covers the study of storage management: static and dynamic allocation, paging
and segmentation, virtual memory and demand paging, page replacement of algorithms
and memory caches and their effect on performance followed by the File management
concepts, such as input/output hardware and software, files, directories and access
mechanisms, file allocation and access algorithms and performance. Finally, the
increasingly important areas of protection and security are discussed like the goals,
authentication, access mechanisms, protection domains, access control lists and
capabilities, and monitoring.
Block 3 covers the advanced topics in Operating Systems like Multiprocessor systems.
Distributed systems and Mobile Operating Systems.
Block 4 covers the case studies on Windows 10, Linux, Android and iOS.
There is a lab component associated with this course (i.e., Section-1 Windows 10 and
Section-2 Linux of MCSL-204 course).
BLOCK INTRODUCTION
The objective of this block is to familiarise you with the issues involved in the design
and implementation of modern operating systems. The course does not concentrate on
any particular operating system or hardware platform. The concepts discussed are
applicable to a variety of systems.
The block is organised into 4 units:
Unit 1 covers the introduction to operating systems;
Unit 2 covers the concept of processes, process states, process switch, threads, CPU
scheduling, various scheduling algorithms and their performance criteria;
Unit 3 covers the interprocess communication, concurrency and synchronization aspects
of the processes, and
Unit 4 covers the deadlocks, conditions for the deadlock, deadlock prevention,
avoidance and recovery.
Introduction to Operating
Systems and Process
Management
6
Operating System:
UNIT 1 OPERATING SYSTEM : AN An Overview
OVERVIEW
Structure
1.1 Introduction
1.2 Objectives
1.3 What is an Operating System?
1.4 Goals of an Operating System
1.5 Generations of Operating Systems
1.5.1 0th Generation
1.5.2 First Generation (1951-1956)
1.5.3 Second Generation (1956-1964)
1.5.4 Third Generation (1964-1979)
1.5.5 Fourth Generation (1979-Present)
1.6 Types of Operating Systems
1.6.1 Batch Processing Operating System
1.6.2 Time Sharing
1.6.3 Real Time Operating System (RTOS)
1.6.4 Multiprogramming Operating System
1.6.5 Multiprocessing System
1.6.6 Networking Operating System
1.6.7 Distributed Operating System
1.6.8 Operating Systems for Embedded Devices
1.7 Desirable Qualities of OS
1.8 Operating Systems : Some Examples
1.8.1 DOS
1.8.2 UNIX
1.8.3 Windows
1.8.4 Macintosh
1.9 Functions of OS
1.9.1 Process Management
1.9.2 Memory Management
1.9.3 Secondary Storage Management
1.9.4 I/O Management
1.9.5 File Management
1.9.6 Protection
1.9.7 Networking
1.9.8 Command Interpretation
1.10 Summary
1.11 Solutions/Answers
1.12 Further Readings 7
Introduction to Operating
Systems and Process 1.1 INTRODUCTION
Management
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.
This unit presents the definition of the operating system, goals of the operating system,
generations of OS, different types of OS and functions of OS.
1.2 OBJECTIVES
After going through this unit, you should be able to:
understand the purpose of an operating system;
describe the general goals of an operating system;
discuss the evolution of operating systems;
describe various functions performed by the OS;
list, discuss and compare various types of OS, and
describe various structures of operating system.
8 provides the basic computing resources. The applications programs define the way in
which these resources are used to solve the computing problems of the users. The Operating System:
An Overview
operating system controls and coordinates the use of the hardware among the various
systems programs and application programs for the various users.
We can view an operating system as a resource allocator. A computer system has
many resources (hardware and software) that may be required to solve a problem:
CPU time, memory space, files storage space, input/output devices etc. The operating
system acts as the manager of these resources and allocates them to specific programs
and users as necessary for their tasks. Since there may be many, possibly conflicting,
requests for resources, the operating system must decide which requests are allocated
resources to operate the computer system fairly and efficiently.
An operating system is a control program. This program controls the execution of
user programs to prevent errors and improper use of the computer. Operating systems
exist because: they are a reasonable way to solve the problem of creating a usable
computing system. The fundamental goal of a computer system is to execute user
programs and solve user problems.
While there is no universally agreed upon definition of the concept of an operating
system, the following is a reasonable starting point:
A computer’s operating system is a group of programs designed to serve two basic
purposes:
To control the allocation and use of the computing system’s resources among
the various users and tasks, and
To provide an interface between the computer hardware and the programmer
that simplifies and makes feasible the creation, coding, debugging, and
maintenance of application programs.
An effective operating system should accomplish the following functions:
Should act as a command interpreter by providing a user friendly environment.
Should facilitate communication with other users.
Facilitate the directory/file creation along with the security option.
Provide routines that handle the intricate details of I/O programming.
Provide access to compilers to translate programs from high-level languages
to machine language
Provide a loader program to move the compiled program code to the
computer’s memory for execution.
Assure that when there are several active processes in the computer, each
will get fair and non-interfering access to the central processing unit for
execution.
Take care of storage and device allocation.
Provide for long term storage of user information in the form of files.
Permit system resources to be shared among users when appropriate, and be
protected from unauthorised or mischievous intervention as necessary.
9
Introduction to Operating Though systems programs such as editors and translators and the various utility programs
Systems and Process
Management (such as sort and file transfer program) are not usually considered part of the operating
system, the operating system is responsible for providing access to these system
resources.
The abstract view of the components of a computer system and the positioning of OS
is shown in the Figure 1.
Operating systems have been evolving over the years. We will briefly look at this
development of the operating systems with respect to the evolution of the hardware
/ architecture of the computer systems in this section. Since operating systems have
historically been closely tied with the architecture of the computers on which they run,
we will look at successive generations of computers to see what their operating systems
were like. We may not exactly map the operating systems generations to the generations
of the computer, but roughly it provides the idea behind them.
10 We can roughly divide them into five distinct generations that are characterized by
hardware component technology, software development, and mode of delivery of Operating System:
An Overview
computer services.
Check Your Progress 1
1) What are the main responsibilities of an Operating System?
........................................................................................................................
........................................................................................................................
........................................................................................................................
........................................................................................................................
These real time operating systems are used to control machinery, scientific instruments
and industrial systems.An RTOS typically has very little user-interface capability, and
no end-user utilities. A very important part of an RTOS is managing the resources of
the computer so that a particular operation executes in precisely the same amount of
time every time it occurs. In a complex machine, having a part move more quickly just
because system resources are available may be just as catastrophic as having it not
move at all because the system is busy.
1.7.1 DOS
DOS (Disk Operating System) was the first widely-installed operating system for
personal computers. It is a master control program that is automatically run when you
start your personal computer (PC). DOS stays in the computer all the time letting you
run a program and manage files. It is a single-user operating system from Microsoft for
the PC. It was the first OS for the PC and is the underlying control program for
Windows 3.1, 95, 98 and ME. Windows NT, 2000 and XP emulate DOS in order to
support existing DOS applications.
1.7.2 UNIX
UNIX operating systems are used in widely-sold workstation products from Sun
Microsystems, Silicon Graphics, IBM, and a number of other companies. The UNIX
environment and the client/server program model were important elements in the
development of the Internet and the reshaping of computing as centered in networks
rather than in individual computers. Linux, a UNIX derivative available in both “free
software” and commercial versions, is increasing in popularity as an alternative to
proprietary operating systems.
UNIX is written in C. Both UNIX and C were developed by AT&T and freely
distributed to government and academic institutions, causing it to be ported to a wider
variety of machine families than any other operating system.As a result, UNIX became
synonymous with “open systems”.
UNIX is made up of the kernel, file system and shell (command line interface). The
major shells are the Bourne shell (original), C shell and Korn shell. The UNIX vocabulary
is exhaustive with more than 600 commands that manipulate data and text in every
way conceivable. Many commands are cryptic, but just as Windows hid the DOS
prompt, the Motif GUI presents a friendlier image to UNIX users. Even with its many
versions, UNIX is widely used in mission critical applications for client/server and
transaction processing systems. The UNIX versions that are widely used are Sun’s
Solaris, Digital’s UNIX, HP’s HP-UX, IBM’s AIX and SCO’s UnixWare. A large
number of IBM mainframes also run UNIX applications, because the UNIX interfaces
were added to MVS and OS/390, which have obtained UNIX branding. Linux, another
variant of UNIX, is also gaining enormous popularity. More details can be studied in
Unit-3 of Block-3 of this course.
1.7.3 WINDOWS
Windows is a personal computer operating system from Microsoft that, together with
some commonly used business applications such as Microsoft Word and Excel, has
become a de facto “standard” for individual users in most corporations as well as in
most homes. Windows contains built-in networking, which allows users to share files
and applications with each other if their PC’s are connected to a network. In large
enterprises, Windows clients are often connected to a network of UNIX and NetWare
servers. The server versions of Windows NT and 2000 are gaining market share,
20
providing a Windows-only solution for both the client and server. Windows is supported Operating System:
An Overview
by Microsoft, the largest software company in the world, as well as the Windows
industry at large, which includes tens of thousands of software developers.
This networking support is the reason why Windows became successful in the first
place. However, Windows 95, 98, ME, NT, 2000 and XP are complicated operating
environments. Certain combinations of hardware and software running together can
cause problems, and troubleshooting can be daunting. Each new version of Windows
has interface changes that constantly confuse users and keep support people busy, and
Installing Windows applications is problematic too. Microsoft has worked hard to
make Windows 2000 and Windows XP more resilient to installation of problems and
crashes in general. More details on Windows 2000 can be studied in Unit-4 of Block
-3 of this course.
1.7.4 MACINTOSH
The Macintosh (often called “the Mac”), introduced in 1984 byApple Computer, was
the first widely-sold personal computer with a graphical user interface (GUI). The
Mac was designed to provide users with a natural, intuitively understandable, and, in
general, “user-friendly” computer interface. This includes the mouse, the use of icons
or small visual images to represent objects or actions, the point-and-click and click-
and-drag actions, and a number of window operation ideas. Microsoft was successful
in adapting user interface concepts first made popular by the Mac in its first Windows
operating system. The primary disadvantage of the Mac is that there are fewer Mac
applications on the market than for Windows. However, all the fundamental applications
are available, and the Macintosh is a perfectly useful machine for almost everybody.
Data compatibility between Windows and Mac is an issue, although it is often overblown
and readily solved.
The Macintosh has its own operating system, Mac OS which, in its latest version is
called Mac OS X. Originally built on Motorola’s 68000 series microprocessors, Mac
versions today are powered by the PowerPC microprocessor, which was developed
jointly by Apple, Motorola, and IBM. While Mac users represent only about 5% of
the total numbers of personal computer users, Macs are highly popular and almost a
cultural necessity among graphic designers and online visual artists and the companies
they work for.
In this section we will discuss some services of the operating system used by its users.
Users of operating system can be divided into two broad classes: command language
users and system call users. Command language users are those who can interact with
operating systems using the commands. On the other hand system call users invoke
services of the operating system by means of run time system calls during the execution
of programs.
More can be read from Block-4 of MCS-203 Operating Systems.
Check Your Progress 2
1) Discuss different views of the Operating Systems.
........................................................................................................................
........................................................................................................................
1.8 FUNCTIONS OF OS
The main functions of an operating system are as follows:
Process Management
Memory Management
Secondary Storage Management
I/O Management
File Management
Protection
Networking Management
Command Interpretation.
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:
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.
The operating system implements the abstract concept of the file by managing mass
storage device, such as types and disks.Also files are normally organised 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.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 authorisation 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
24
unprotected resource cannot defend against use (or misuse) by an unauthorised or Operating System:
An Overview
incompetent user. More on protection and security can be studied in Unit-4 of
Block-3.
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
with each other through various communication lines, such as high speed buses or
telephone lines. 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.9 SUMMARY
This Unit presented the principle operation of an operating system. In this unit we had
briefly described about the history, the generations and the types of operating systems.
An operating system is a program 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 programs. The primary goal of an operating
system is to make the computer convenient to use. And the secondary goal is to use
the hardware in an efficient manner.
Operating systems may be classified by both how many tasks they can perform
“simultaneously” and by how many users can be using the system “simultaneously”.
That is: single-user or multi-user and single-task or multi-tasking. A multi-user
system must clearly be multi-tasking. In the next unit we will discuss the concept of
processes and their management by the OS.
1.10 SOLUTIONS/ANSWERS
Check Your Progress 1
1) The most important type of system software is the operating system.An operating
system has three main responsibilities:
Perform basic tasks, such as recognising input from the keyboard, sending
output to the display screen, keeping track of files and directories on the disk,
and controlling peripheral devices such as disk drives and printers.
Ensure that different programs and users running at the same time do not
interfere with each other.
26
Provide a software platform on top of which other programs (i.e., application Operating System:
An Overview
software) can run.
The first two responsibilities address the need for managing the computer hardware
and the application programs that use the hardware. The third responsibility focuses
on providing an interface between application software and hardware so that application
software can be efficiently developed. Since the operating system is already responsible
for managing the hardware, it should provide a programming interface for application
developers.
Check Your Progress 2
1) The following are the different views of the operating system.
As a scheduler/allocator:
The operating system has resources for which it is in charge.
Responsible for handing them out (and later recovering them).
Resources include CPU, memory, I/O devices, and disk space.
As a virtual machine:
Operating system provides a “new” machine.
– This machine could be the same as the underlying machine.Allows many
users to believe they have an entire piece of hardware to themselves.
– This could implement a different, perhaps more powerful, machine. Or
just a different machine entirely. It may be useful to be able to completely
simulate another machine with your current hardware.
As a multiplexer:
Allows sharing of resources, and provides protection from interference.
Provides for a level of cooperation between users.
Economic reasons: we have to take turns.
2) Batch Processing: This strategy involves reading a series of jobs (called a batch)
into the machine and then executing the programs for each job in the batch. This
approach does not allow users to interact with programs while they operate.
Time Sharing: This strategy supports multiple interactive users. Rather than
preparing a job for execution ahead of time, users establish an interactive session
with the computer and then provide commands, programs and data as they are
needed during the session.
Real Time: This strategy supports real-time and process control systems. These
are the types of systems which control satellites, robots, and air-traffic control.
The dedicated strategy must guarantee certain response times for particular
computing tasks or the application is useless.
Check Your Progress 3
1) The advantage of having a multi-user operating system is that normally the hardware
is very expensive, and it lets a number of users share this expensive resource. This 27
Introduction to Operating means the cost is divided amongst the users. It also makes better use of the
Systems and Process
Management resources. Since the resources are shared, they are more likely to be in use than
sitting idle being unproductive.
One limitation with multi-user computer systems is that as more users access it,
the performance becomes slower and slower. Another limitation is the cost of
hardware, as a multi-user operating system requires a lot of disk space and memory.
In addition, the actual software for multi-user operating systems tend to cost more
than single-user operating systems.
2) A multi-tasking operating system provides the ability to run more than one program
at once. For example, a user could be running a word processing package, printing
a document, copying files to the floppy disk and backing up selected files to a tape
unit. Each of these tasks the user is doing appears to be running at the same time.
A multi-tasking operating system has the advantage of letting the user run more
than one task at once, so this leads to increased productivity. The disadvantage is
that more programs that are run by the user, the more memory is required.
3) An operating system for a security control system (such as a home alarm system)
would consist of a number of programs. One of these programs would gain control
of the computer system when it is powered on, and initialise the system. The first
task of this initialise program would be to reset (and probably test) the hardware
sensors and alarms. Once the hardware initialisation was complete, the operating
system would enter a continual monitoring routine of all the input sensors. If the
state of any input sensor is changed, it would branch to an alarm generation routine.
28
Operating System:
UNIT 2 PROCESSES An Overview
Structure
2.1 Introduction
2.2 Objectives
2.3 The Concept of Process
2.3.1 Implicit and Explicit Tasking
2.3.2 Processes Relationship
2.3.3 Process States
2.3.4 Implementation of Processes
2.3.5 Process Hierarchy
2.3.6 Threads
2.3.7 Levels of Threads
2.4 System Calls for Process Management
2.5 Process Scheduling
2.5.1 Scheduling Objectives
2.5.2 Types of Schedulers
2.5.3 Scheduling Criteria
2.6 Scheduling Algorithms
2.6.1 First Come First Serve (FCFS)
2.6.2 Shortest Job First (SJF)
2.6.3 Round Robin (RR)
2.6.4 Shortest Remaining Time Next (SRTN)
2.6.5 Priority Based Scheduling or Event Driven (ED) Scheduling
2.7 Performance Evaluation of the Scheduling Algorithms
2.8 Summary
2.9 Solutions/Answers
2.10 Further Readings
2.1 INTRODUCTION
In the earlier unit we have studied the overview and the functions of an operating
system. In this unit we will have detailed discussion on the processes and their
management by the operating system. The other resource management features of
operating systems will be discussed in the subsequent units.
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 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.
In general, a process will need certain resources such as CPU time, memory, files, I/O
devices, etc., to accomplish its task. These resources are given to the process when it 29
Introduction to Operating is created. In addition to the various physical and logical resources that a process
Systems and Process
Management obtains when it is created, some initialisation data (input) may be passed along. For
example, a process whose function is to display the status of a file, say F1, on the
screen, will get the name of the file F1 as an input and execute the appropriate program
to obtain the desired information.
We emphasize that a program by itself is not a process; a program is a passive entity,
while a process is an active entity. It is known that two processes may be associated
with the same program; they are nevertheless considered two separate execution
sequences.
A process is the unit of work in a system. Such a system consists of a collection of
processes, some of which are operating system processes, those that execute system
code, and the rest being user processes, those that execute user code. All of those
processes can potentially execute concurrently.
The operating system is responsible for the following activities in connection with
processes managed.
The creation and deletion of both user and system processes;
The suspension is resumption of processes;
The provision of mechanisms for process synchronization, and
The provision of mechanisms for deadlock handling.
We will learn the operating system view of the processes, types of schedulers, different
types of scheduling algorithms, in the subsequent sections of this unit.
2.2 OBJECTIVES
After going through this unit, you should be able to:
understand the concepts of process, various states in the process and their
scheduling;
define a process control block;
classify different types of schedulers;
understand various types of scheduling algorithms, and
compare the performance evaluation of the scheduling algorithms.
Transition 1 appears when a process discovers that it cannot continue. In order to get
into blocked state, some systems must execute a system call block. In other systems,
when a process reads from a pipe or special file and there is no input available, the
process is automatically blocked.
Transition 2 and 3 are caused by the process scheduler, a part of the operating system.
Transition 2 occurs when the scheduler decides that the running process has run long
enough, and it is time to let another process have some CPU time. Transition 3 occurs
when all other processes have had their share and it is time for the first process to run
again.
Transition 4 appears when the external event for which a process was waiting was
happened. If no other process is running at that instant, transition 3 will be triggered
immediately, and the process will start running. Otherwise it may have to wait in ready
state for a little while until the CPU is available.
Using the process model, it becomes easier to think about what is going on inside the
system. There are many processes like user processes, disk processes, terminal
processes, and so on, which may be blocked when they are waiting for something to
happen. When the disk block has been read or the character typed, the process waiting
for it is unblocked and is ready to run again.
To implement the process model, the operating system maintains a table, an array of
structures, called the process table or process control block (PCB) or Switch frame.
Each entry identifies a process with information such as process state, its program
counter, stack pointer, memory allocation, the status of its open files, its accounting
and scheduling information. In other words, it must contain everything about the process
that must be saved when the process is switched from the running state to the ready
state so that it can be restarted later as if it had never been stopped. The following is
the information stored in a PCB.
Process state, which may be new, ready, running, waiting or halted;
Process number, each process is identified by its process number, called process
ID;
Program counter, which indicates the address of the next instruction to be executed
for this process;
CPU registers, which vary in number and type, depending on the concrete
microprocessor architecture;
Memory management information, which include base and bounds registers or
page table;
I/O status information, composed I/O requests, I/O devices allocated to this process,
a list of open files and so on;
Processor scheduling information, which includes process priority, pointers to
scheduling queues and any other scheduling parameters;
List of open files.
A process structure block is shown in Figure 2.
Context Switch
A context switch (also sometimes referred to as a process switch or a task switch)
is the switching of the CPU (central processing unit) from one process or to another. 35
Introduction to Operating A context is the contents of a CPU’s registers and program counter at any point in
Systems and Process
Management time.
A context switch is sometimes described as the kernel suspending execution of one
process on the CPU and resuming execution of some other process that had previously
been suspended.
Context Switch: Steps
In a context switch, the state of the first process must be saved somehow, so that,
when the scheduler gets back to the execution of the first process, it can restore this
state and continue normally.
The state of the process includes all the registers that the process may be using, especially
the program counter, plus any other operating system specific data that may be necessary.
Often, all the data that is necessary for state is stored in one data structure, called a
process control block (PCB). Now, in order to switch processes, the PCB for the first
process must be created and saved. The PCBs are sometimes stored upon a per-
process stack in the kernel memory, or there may be some specific operating system
defined data structure for this information.
Let us understand with the help of an example. Suppose if two processes A and B are
in ready queue. If CPU is executing Process A and Process B is in wait state. If an
interrupt occurs for ProcessA, the operating system suspends the execution of the first
process, and stores the current information of Process A in its PCB and context to the
second process namely Process B. In doing so, the program counter from the PCB of
Process B is loaded, and thus execution can continue with the new process. The
switching between two processes, ProcessAand Process B is illustrated in the Figure
3 given below:
Old or primitive operating system like MS-DOS are not multiprogrammed so when
one process starts another, the first process is automatically blocked and waits until
the second is finished.
2.2.6 Threads
Threads, sometimes called lightweight processes (LWPs) are independently scheduled
parts of a single program. We say that a task is multithreaded if it is composed of
several independent sub-processes which do work on common data, and if each of
those pieces could (at least in principle) run in parallel.
If we write a program which uses threads – there is only one program, one executable
file, one task in the normal sense. Threads simply enable us to split up that program 37
Introduction to Operating into logically separate pieces, and have the pieces run independently of one another,
Systems and Process
Management until they need to communicate. In a sense, threads are a further level of object
orientation for multitasking systems. They allow certain functions to be executed in
parallel with others.
On a truly parallel computer (several CPUs) we might imagine parts of a program
(different subroutines) running on quite different processors, until they need to
communicate. When one part of the program needs to send data to the other part, the
two independent pieces must be synchronized, or be made to wait for one another.
But what is the point of this? We can always run independent procedures in a program
as separate programs, using the process mechanisms we have already introduced.
They could communicate using normal interprocesses communication. Why introduce
another new concept? Why do we need threads?
The point is that threads are cheaper than normal processes, and that they can be
scheduled for execution in a user-dependent way, with less overhead. Threads are
cheaper than a whole process because they do not have a full set of resources each.
Whereas the process control block for a heavyweight process is large and costly to
context switch, the PCBs for threads are much smaller, since each thread has only a
stack and some registers to manage. It has no open file lists or resource lists, no
accounting structures to update.All of these resources are shared by all threads within
the process. Threads can be assigned priorities – a higher priority thread will get put to
the front of the queue. Let’s define heavy and lightweight processes with the help of a
table.
In modern operating systems, there are two levels at which threads operate: system or
kernel threads and user level threads. If the kernel itself is multithreaded, the scheduler
assigns CPU time on a thread basis rather than on a process basis. A kernel level
thread behaves like a virtual CPU, or a power-point to which user-processes can
connect in order to get computing power. The kernel has as many system level threads
as it has CPUs and each of these must be shared between all of the user-threads on the
system. In other words, the maximum number of user level threads which can be active
at any one time is equal to the number of system level threads, which in turn is equal to
the number of CPUs on the system.
Since threads work “inside” a single task, the normal process scheduler cannot normally
tell which thread to run and which not to run – that is up to the program. When the
kernel schedules a process for execution, it must then find out from that process which
is the next thread it must execute. If the program is lucky enough to have more than one
processor available, then several threads can be scheduled at the same time.
Some important implementations of threads are:
The Mach System / OSF1 (user and system level)
Solaris 1 (user level)
Solaris 2 (user and system level)
OS/2 (system level only)
NT threads (user and system level)
IRIX threads
POSIX standardized user threads interface.
Check Your Progress 1
1) Explain the difference between a process and a thread with some examples.
........................................................................................................................
........................................................................................................................
........................................................................................................................
2) Identify the different states a live process may occupy and show how a process
moves between these states.
........................................................................................................................
........................................................................................................................
........................................................................................................................
3) Define what is meant by a context switch. Explain the reason many systems use
two levels of scheduling.
........................................................................................................................
........................................................................................................................
........................................................................................................................ 39
Introduction to Operating
Systems and Process 2.3 SYSTEM CALLS FOR PROCESS
Management
MANAGEMENT
In this section we will discuss system calls typically provided by the kernels of
multiprogramming operating systems for process management. System calls provide
the interface between a process and the operating system. These system calls are the
routine services of the operating system.As an example of how system calls are used,
consider writing a simple program to read data from one file and to copy them to
another file. There are two names of two different files in which one input file and the
other is the output file. One approach is for the program to ask the user for the names
of the two files. In an interactive system, this approach will require a sequence of
system calls, first to write a prompting message on the screen and then to read from the
keyboard the character that the two files have. Once the two file names are obtained
the program must open the input file and create the output file. Each of these operations
requires another system call and may encounter possible error conditions. When the
program tries to open the input file, it may find that no file of that name exists or that the
file is protected against access. In these cases the program should print the message on
the console and then terminate abnormally which require another system call. If the
input file exists then we must create the new output file. We may find an output file with
the same name. This situation may cause the program to abort or we may delete the
existing file and create a new one. After opening both files, we may enter a loop that
reads from input file and writes to output file. Each read and write must return status
information regarding various possible error conditions. Finally, after the entire file is
copied the program may close both files. Examples of some operating system calls are:
Create: In response to the create call the operating system creates a new process
with the specified or default attributes and identifier. Some of the parameters definable
at the process creation time include:
level of privilege, such as system or user
priority
size and memory requirements
maximum data area and/or stack size
memory protection information and access rights
other system dependent data.
Delete: The delete service is also called destroy, terminate or exit. Its execution causes
the operating system to destroy the designated process and remove it from the system.
Abort: It is used to terminate the process forcibly.Although a process could conceivably
abort itself, the most frequent use of this call is for involuntary terminations, such as
removal of malfunctioning process from the system.
Fork/Join:Another method of process creation and termination is by means of FORK/
JOIN pair, originally introduced as primitives for multiprocessor system. The FORK
operations are used to split a sequence of instruction into two concurrently executable
sequences. JOIN is used to merge the two sequences of code divided by the FORK
40 and it is available to a parent process for synchronization with a child.
Suspend: The suspend system call is also called BLOCK in some systems. The Processes
Check Your Progress 2
1) Distinguish between a foreground and a background process in UNIX.
........................................................................................................................
........................................................................................................................
........................................................................................................................
2) Identify the information which must be maintained by the operating system for
each live process.
........................................................................................................................
........................................................................................................................
........................................................................................................................
from running to ready without the process requesting it. An OS implementing this
algorithms switches to the processing of a new request before completing the processing
of the current request. The preempted request is put back into the list of the pending
requests. Its servicing would be resumed sometime in the future when it is scheduled
again. Preemptive scheduling is more useful in high priority process which requires
immediate response. For example, in Real time system the consequence of missing
one interrupt could be dangerous.
Round Robin scheduling, priority based scheduling or event driven scheduling and
SRTN are considered to be the preemptive scheduling algorithms.
First come First Served (FCFS) and Shortest Job First (SJF), are considered to be
the non-preemptive scheduling algorithms.
The decision whether to schedule preemptive or not depends on the environment and
the type of application most likely to be supported by a given operating system.
Under some circumstances, CPU utilisation can also suffer. In the situation described
above, once a CPU-bound process does issue an I/O request, the CPU can return to
process all the I/O-bound processes. If their processing completes before the CPU-
bound process’s I/O completes, the CPU sits idle. So with no preemption, component
utilisation and the system throughput rate may be quite low.
Example:
Calculate the turn around time, waiting time, average turnaround time, average waiting
time, throughput and processor utilization for the given set of processes that arrive at a
given arrive time shown in the table, with the length of processing time given in
milliseconds:
45
Introduction to Operating
Systems and Process
Management
If the processes arrive as per the arrival time, the Gantt chart will be
Using SJF scheduling because the shortest length of process will first get execution, the
Gantt chart will be:
Because the shortest processing time is of the process P4, then process P1 and then
46
P3 and Process P2. The waiting time for process P1 is 3 ms, for process P2 is 16 ms, Processes
for process P3 is 9 ms and for the process P4 is 0 ms as –
47
Introduction to Operating
Systems and Process
Management
At time 0, only process P1 has entered the system, so it is the process that executes.
At time 1, process P2 arrives. At that time, process P1 has 4 time units left to execute
At this juncture process 2’s processing time is less compared to the P1 left out time (4
units). So P2 starts executing at time 1. At time 2, process P3 enters the system with
the processing time 5 units. Process P2 continues executing as it has the minimum
number of time units when compared with P1 and P3.At time 3, process P2 terminates
and process P4 enters the system. Of the processes P1, P3 and P4, P4 has the smallest
remaining execution time so it starts executing. When process P1 terminates at time
10, process P3 executes. The Gantt chart is shown below:
Turnaround time for each process can be computed by subtracting the time it terminated
from the arrival time.
Turn around Time = t(Process Completed)– t(Process Submitted)
The turnaround time for each of the processes is:
P1: 10 – 0 = 10
P2: 3–1= 2
P3: 15 – 2 = 13
P4: 6–3= 3
48
The average turnaround time is (10+2+13+3) / 4 = 7 Processes
The waiting time can be computed by subtracting processing time from turnaround
time, yielding the following 4 results for the processes as
P1: 10 – 5 = 5
P2: 2 – 2 = 0
P3: 13 – 5 = 8
P4: 3 – 3 = 0
The average waiting time = (5+0+8+0) / 4 = 3.25milliseconds
Four jobs executed in 15 time units, so throughput is 15 / 4 = 3.75 time units/job.
Using priority scheduling we would schedule these processes according to the following
Gantt chart:
49
Introduction to Operating Average turn around time = (1+6+16+18+19) / 5 = 60/5 = 12
Systems and Process
Management
Average waiting time = (6+0+16+18+1) / 5 = 8.2
Throughput = 5/19 = 0.26
Processor utilization = (30/30) * 100 = 100%
Priorities can be defined either internally or externally. Internally defined priorities use
one measurable quantity or quantities to complete the priority of a process.
Maximize throughput.
For example, assume that we have the following five processes arrived at time 0, in the
order given with the length of CPU time given in milliseconds.
First consider the FCFS scheduling algorithm for the set of processes.
For FCFS scheduling the Gantt chart will be:
Now consider the SJF scheduling, the Gantt chart will be:
50
Processes
Check Your Progress 3
1) Explainthe difference between voluntary or co-operative scheduling and preemptive
scheduling. Give two examples of preemptive and of non-preemptive scheduling
algorithms.
........................................................................................................................
........................................................................................................................
........................................................................................................................
........................................................................................................................
3) Draw the Gantt chart for the FCFS policy, considering the following set of processes
that arrive at time 0, with the length of CPU time given in milliseconds.Also calculate
theAverage Waiting Time. 51
Introduction to Operating ........................................................................................................................
Systems and Process
Management
........................................................................................................................
........................................................................................................................
........................................................................................................................
4) For the given five processes arriving at time 0, in the order with the length of CPU
time in milliseconds:
Consider the FCFS, SJF and RR (time slice= 10 milliseconds) scheduling algorithms
for the above set of process which algorithm would give the minimum average
waiting time?
........................................................................................................................
........................................................................................................................
........................................................................................................................
2.7 SUMMARY
A process is an instance of a program in execution. A process can be defined by the
system or process is an important concept in modem operating system. Processes
provide a suitable means for informing the operating system about independent activities
that may be scheduled for concurrent execution. Each process is represented by a
process control block (PCB). Several PCB’s can be linked together to form a queue
of waiting processes. The selection and allocation of processes is done by a scheduler.
There are several scheduling algorithms. We have discussed FCFS, SJF, RR, SJRT
and priority algorithms along with the performance evaluation.
2.8 SOLUTIONS/ANSWERS
Check Your Progress 1
52 1) A process is an instance of an executing program and its data. For example, if you
were editing 3 files simultaneously, you would have 3 processes, even though they Processes
2) Some processes are more critical to overall operation than others e.g., kernel
activity. I/O bound processes, which seldom use a full quantum, need a boost
over compute bound tasks. This priority can be implemented by any combination
of higher positioning in the ready queue for higher priority more frequent occurrences
in the ready list for different priorities different quantum lengths for different
priorities. Priority scheduling is liable to starvation. Asuccession of high priority
processes may result in a low priority process never reaching the head of the
ready list. Priority is normal a combination of static priority (set by the user or the
class of the process) and a dynamic adjustment based on it’s history (e.g., how
long it has been waiting). NT and Linux also boost priority when processes return
from waiting for I/O.
3) If the process arrives in the order P1, P2 and P3, then the Gantt chart will be as:
From the above calculations of average waiting time we found that SJF policy results
in less than one half of the average waiting time obtained from FCFS, while Round
Robin gives intermediate result.
56
Processes
UNIT 3 INTERPROCESS COMMUNICATION
AND SYNCHRONIZATION
Structure
3.1 Introduction
3.2 Objectives
3.3 Interprocess Communication
3.3.1 Shared-Memory System
3.3.2 Message-Passing System
3.4 Interprocess Synchronization
3.4.1 Serialization
3.4.2 Mutexes: Mutual Exclusion
3.4.3 Critical Sections: The Mutex Solution
3.4.4 Dekker’s Solution for Mutual Exclusion
3.4.5 Bakery’s Algorithm
3.5 Semaphores
3.6 Classical Problems in Concurrent Programming
3.6.1 Producers/Consumers Problem
3.6.2 Readers and Writers Problem
3.6.3 Dining- Philosophers Problem
3.6.4 Sleeping Barber Problem
3.7 Locks
3.8 Monitors and Condition Variables
3.9 Summary
3.10 Solution/Answers
3.11 Further Readings
3.1 INTRODUCTION
In the earlier unit we have studied the concept of processes. In addition to process
scheduling, another important responsibility of the operating system is process
synchronization. Synchronization involves the orderly sharing of system resources by
processes.
Concurrency specifies two or more sequential programs (a sequential program specifies
sequential execution of a list of statements) that may be executed concurrently as a
parallel process. For example, an airline reservation system that involves processing
transactions from many terminals has a natural specification as a concurrent program in
which each terminal is controlled by its own sequential process. Even when processes
are not executed simultaneously, it is often easier to structure as a collection of
cooperating sequential processes rather than as a single sequential program.
A simple batch operating system can be viewed as 3 processes-a reader process, an
executor process and a printer process. The reader reads cards from card reader and 57
Introduction to Operating places card images in an input buffer. The executor process reads card images from
Systems and Process
Management input buffer and performs the specified computation and store the result in an output
buffer. The printer process retrieves the data from the output buffer and writes them to
a printer. Concurrent processing is the basis of operating system which supports
multiprogramming.
Share Data: A segment of memory must be available to both the processes. (Most
memory is locked to a single process).
Waiting: Some processes wait for other processes to give a signal before continuing.
This is an issue of synchronization.
In this unit, let us study the concept of interprocess communication and synchronization,
need of semaphores, classical problems in concurrent processing, critical regions,
monitors and message passing.
3.2 OBJECTIVES
After studying this unit, you should be able to:
identify the significance of interprocess communication and synchronization;
describe the two ways of interprocess communication namely shared memory
and message passing;
discuss the usage of semaphores, locks and monitors in interprocess and
synchronization, and
solve classical problems in concurrent programming.
58
Interprocess Communication
3.3 INTERPROCESS COMMUNICATION and Synchronization
Direct Communication
In direct communication, each process that wants to send or receive a message must
explicitly name the recipient or sender of the communication. In this case, the send and
receive primitives are defined as follows:
send (P, message) To send a message to process P
receive (Q, message) To receive a message from process Q
This scheme shows the symmetry in addressing, i.e., both the sender and the receiver
have to name one another in order to communicate. In contrast to this, asymmetry in
addressing can be used, i.e., only the sender has to name the recipient; the recipient is
not required to name the sender. So the send and receive primitives can be defined as
follows:
60
send (P, message) To send a message to the process P Interprocess Communication
and Synchronization
receive (id, message) To receive a message from any process; id is set to
the name of the process with whom the
communication has taken place.
Indirect Communication
With indirect communication, the messages are sent to, and received from a mailbox.
A mailbox can be abstractly viewed as an object into which messages may be placed
and from which messages may be removed by processes. In order to distinguish one
from the other, each mailbox owns a unique identification.Aprocess may communicate
with some other process by a number of different mailboxes. The send and receive
primitives are defined as follows:
send (A, message) To send a message to the mailbox A
receive (A, message) To receive a message from the mailbox A
Mailboxes may be owned either by a process or by the system. If the mailbox is
owned by a process, then we distinguish between the owner who can only receive
from this mailbox and user who can only send message to the mailbox. When a process
that owns a mailbox terminates, its mailbox disappears. Any process that sends a
message to this mailbox must be notified in the form of an exception that the mailbox
no longer exists.
If the mailbox is owned by the operating system, then it has an existence of its own,
i.e., it is independent and not attached to any particular process. The operating system
provides a mechanism that allows a process to: a) create a new mailbox, b) send and
receive message through the mailbox and c) destroy a mailbox. Since all processes
with access rights to a mailbox may terminate, a mailbox may no longer be accessible
by any process after some time. In this case, the operating system should reclaim
whatever space was used for the mailbox.
Capacity Link
A link has some capacity that determines the number of messages that can temporarily
reside in it. This propriety can be viewed as a queue of messages attached to the link.
Basically there are three ways through which such a queue can be implemented:
Zero capacity: This link has a message queue length of zero, i.e., no message can
wait in it. The sender must wait until the recipient receives the message. The two
processes must be synchronized for a message transfer to take place. The zero-capacity
link is referred to as a message-passing system without buffering.
Bounded capacity: This link has a limited message queue length of n, i.e., at most n
messages can reside in it. If a new message is sent, and the queue is not full, it is placed
in the queue either by copying the message or by keeping a pointer to the message and
the sender should continue execution without waiting. Otherwise, the sender must be
delayed until space is available in the queue.
Unbounded capacity: This queue has potentially infinite length, i.e., any number of
messages can wait in it. That is why the sender is never delayed.
Bounded and unbounded capacity link provide message-passing system with automatic
buffering. 61
Introduction to Operating Messages
Systems and Process
Management
Messages sent by a process may be one of three varieties: a) fixed-sized, b) variable-
sized and c) typed messages. If only fixed-sized messages can be sent, the physical
implementation is straightforward. However, this makes the task of programming more
difficult. On the other hand, variable-size messages require more complex physical
implementation, but the programming becomes simpler.Typed messages, i.e., associating
a type with each mailbox, are applicable only to indirect communication. The messages
that can be sent to, and received from a mailbox are restricted to the designated type.
3.4.1 Serialization
The key idea in process synchronization is serialization. This means that we have to
go to some pains to undo the work we have put into making an operating system
perform several tasks in parallel.As we mentioned, in the case of print queues, parallelism
is not always appropriate.
Synchronization is a large and difficult topic, so we shall only undertake to describe the
problem and some of the principles involved here.
There are essentially two strategies to serializing processes in a multitasking environment.
The scheduler can be disabled for a short period of time, to prevent control
being given to another process during a critical action like modifying shared
data. This method is very inefficient on multiprocessor machines, since all
other processors have to be halted every time one wishes to execute a critical
section.
A protocol can be introduced which all programs sharing data must obey.
The protocol ensures that processes have to queue up to gain access to shared
data. Processes which ignore the protocol ignore it at their own peril (and the
peril of the remainder of the system!). This method works on multiprocessor
machines also, though it is more difficult to visualize. The responsibility of
serializing important operations falls on programmers. The OS cannot impose
any restrictions on silly behaviour-it can only provide tools and mechanisms
to assist the solution of the problem.
Where more processes are involved, some modifications are necessary to this algorithm.
The key to serialization here is that, if a second process tries to obtain the mutex, when
64 another already has it, it will get caught in a loop, which does not terminate until the
other process has released the mutex. This solution is said to involve busy waiting-i.e., Interprocess Communication
and Synchronization
the program actively executes an empty loop, wasting CPU cycles, rather than moving
the process out of the scheduling queue. This is also called a spin lock, since the
system ‘spins’ on the loop while waiting. Let us see another algorithm which handles
critical section problem for n processes.
It should be noted that Dekker’s solution does rely on one very simple assumption
about the underlying hardware; it assumes that if two processes attempt to write two
different values in the same memory location at the same time, one or the other value
will be stored and not some mixture of the two. This is called the atomic update 65
Introduction to Operating assumption. The atomically updatable unit of memory varies considerably from one
Systems and Process
Management system to another; on some machines, any update of a word in memory is atomic, but
an attempt to update a byte is not atomic, while on others, updating a byte is atomic
while words are updated by a sequence of byte updates.
If processes P i and P j receive the same number, if i < j , then P i is served first;
else P j is served first.
The numbering scheme always generates numbers in increasing order of
enumeration; i.e., 1,2,3,3,3,3,4,5...
Notation <= lexicographical order (ticket #, process id #)
o (a,b) < (c,d) if a < c or if a = c and b < d
o max(a , . . . , a ) is a number, k , such that k >= a for i = 0, . . . , n - 1
0 n-1i
Shared data
boolean choosing[n]; //initialise all to false
int number[n]; //initialise all to 0
Data structures are initialized to false and 0, respectively.
The algorithm is as follows:
do
{
choosing[i] = true;
number[i] = max(number[0], number[1], ...,number[n-1]) + 1;
choosing[i] = false;
for(int j = 0; j < n; j++)
{
while (choosing[j]== true)
{
/*do nothing*/
}
while ((number[j]!=0) &&
(number[j],j)< (number[i],i))
// see Reference point
{
/*do nothing*/
}
}
66
do critical section Interprocess Communication
and Synchronization
number[i] = 0;
do remainder section
} while (true)
In the next section we will study how the semaphores provides a much more organize
approach of synchronization of processes.
3.4 SEMAPHORES
Semaphores provide a much more organized approach to controlling the interaction of
multiple processes than would be available if each user had to solve all interprocess
communications using simple variables, but more organization is possible. In a sense,
semaphores are something like the goto statement in early programming languages;
they can be used to solve a variety of problems, but they impose little structure on the
solution and the results can be hard to understand without the aid of numerous comments.
Just as there have been numerous control structures devised in sequential programs to
reduce or even eliminate the need for goto statements, numerous specialized concurrent
control structures have been developed which reduce or eliminate the need for
semaphores.
Definition: The effective synchronization tools often used to realize mutual exclusion
in more complex systems are semaphores. A semaphore S is an integer variable which
can be accessed only through two standard atomic operations: wait and signal. The
definition of the wait and signal operations are:
wait(S): while S < 0 do skip;
S := S – 1;
signal(S): S := S + 1;
or in C language notation we can write it as:
wait(s)
{
while (S<=0)
{
/*do nothing*/
}
S= S-1;
}
signal(S)
{
S = S + 1;
}
It should be noted that the test (S < 0) and modification of the integer value of S which
is S := S – 1 must be executed without interruption. In general, if one process modifies
the integer value of S in the wait and signal operations, no other process can
simultaneously modify that same S value. We briefly explain the usage of semaphores
in the following example:
67
Introduction to Operating Consider two currently running processes: P1 with a statement S 1 and P2 with a
Systems and Process
Management statement S2. Suppose that we require that S 2be executed only after S 1has completed.
This scheme can be implemented by letting P 1 and P2 share a common semaphore
synch, initialised to 0, and by inserting the statements:
S1 ;
signal(synch);
in the process P1 and the statements:
wait(synch);
S2;
in the process P 2.
Since synch is initialised to 0, P2 will execute S2 only after P1 has involved signal
(synch), which is after S1.
The disadvantage of the semaphore definition given above is that it requires busy-
waiting, i.e., while a process is in its critical region, any either process it trying to enter
its critical region must continuously loop in the entry code. It’s clear that through busy-
waiting, CPU cycles are wasted by which some other processes might use those
productively.
To overcome busy-waiting, we modify the definition of the wait and signal operations.
When a process executes the wait operation and finds that the semaphore value is not
positive, the process blocks itself. The block operation places the process into a waiting
state. Using a scheduler the CPU then can be allocated to other processes which are
ready to run.
A process that is blocked, i.e., waiting on a semaphore S, should be restarted by the
execution of a signal operation by some other processes, which changes its state from
blocked to ready. To implement a semaphore under this condition, we define a
semaphore as:
struct semaphore
{
int value;
List *L; //a list of processes
}
Each semaphore has an integer value and a list of processes. When a process must
wait on a semaphore, it is added to this list. A signal operation removes one process
from the list of waiting processes, and awakens it. The semaphore operation can be
now defined as follows:
wait(S)
{
S.value = S.value -1;
if (S.value <0)
{
add this process to S.L;
block;
68 }
} Interprocess Communication
and Synchronization
signal(S)
{
S.value = S.value + 1;
if (S.value <= 0)
{
remove a process P from S.L;
wakeup(P);
}
}
The block operation suspends the process. The wakeup(P) operation resumes the
execution of a blocked process P. These two operations are provided by the operating
system as basic system calls.
One of the almost critical problem concerning implementing semaphore is the situation
where two or more processes are waiting indefinitely for an event that can be only
caused by one of the waiting processes: these processes are said to be deadlocked.
To illustrate this, consider a system consisting of two processes P1 and P2, each accessing
two semaphores S and Q, set to the value one:
P1 P2
wait(S); wait(Q);
wait(Q); wait(S);
... ...
signal(S); signal(Q);
signal(Q); signal(S);
Suppose P1 executes wait(S) and then P2 executes wait(Q). When P1 executes wait(Q),
it must wait until P 2 executes signal(Q). It is no problem, P 2 executes wait(Q), then
signal(Q). Similarly, when P2 executes wait(S), it must wait until P1 executes signal(S).
Thus these signal operations cannot be carried out, P 1 and P2 are deadlocked. It is
clear, that a set of processes are in a deadlocked state, when every process in the set
is waiting for an event that can only be caused by another process in the set.
3.6 LOCKS
Locks are another synchronization mechanism. A lock has got two atomic
operations (similar to semaphore) to provide mutual exclusion. These two operations
are Acquire and Release. A process will acquire a lock before accessing a shared
variable, and later it will be released. A process locking a variable will run the
following code:
Lock-Acquire();
critical section
Lock-Release();
The difference between a lock and a semaphore is that a lock is released only by the
process that have acquired it earlier.As we discussed above any process can increment
the value of the semaphore. To implement locks, here are some things you should keep
inmind:
Making sure that only the process that acquires the lock will release the lock.
Check Your Progress 1
1) What are race conditions? How race conditions occur in Operating Systems?
........................................................................................................................
........................................................................................................................
3.8 SUMMARY
Interprocess communication provides a mechanism to allow process to communicate
78 with other processes. Interprocess communication system is best provided by a message
passing system. Message systems can be defined in many different ways. If there are a Interprocess Communication
and Synchronization
collection of cooperating sequential processes that share some data, mutual exclusion
must be provided. There are different methods for achieving the mutual exclusion.
Different algorithms are available for solving the critical section problem which we
have discussion in this unit. The bakery algorithm is used for solving the n process
critical section problem.
Interprocess synchronization provides the processes to synchronize their activities.
Semaphores can be used to solve synchronization problems. Semaphore can only be
accessed through two atomic operations and can be implemented efficiently. The two
operations are wait and signal.
There are a number of classical synchronization problems which we have discussed in
this unit (such as producer- consumer problem, readers – writers problem and d dining
– philosophers problem). These problems are important mainly because they are
examples for a large class of concurrency-control problems. In the next unit we will
study an important aspect called as “Deadlocks”
3.9 SOLUTIONS/ANSWERS
Check Your Progress 1
1) Processes that are working together share some common storage (main memory,
file etc.) that each process can read and write. When two or more processes are
reading or writing some shared data and the final result depends on who runs
precisely when, are called race conditions. Concurrently executing threads that
share data need to synchronize their operations and processing in order to avoid
race condition on shared data. Only one “customer” thread at a time should be
allowed to examine and update the shared variable.
Race conditions are also possible in Operating Systems. If the ready queue is
implemented as a linked list and if the ready queue is being manipulated during the
handling of an interrupt, then interrupts must be disabled to prevent another interrupt
before the first one completes. If interrupts are not disabled than the linked list
could become corrupt.
2) The most synchronization problem confronting cooperating processes, is to control
the access between the shared resources. Suppose two processes share access
to a file and at least one of these processes can modify the data in this shared area
of memory. That part of the code of each program, where one process is reading
from or writing to a shared memory area, is a critical section of code; because
we must ensure that only one process execute a critical section of code at a time.
The critical section problem is to design a protocol that the processes can use to
coordinate their activities when one wants to enter its critical section of code.
3) This seems like a fairly easy solution. The three smoker processes will make a
cigarette and smoke it. If they can’t make a cigarette, then they will go to sleep.
The agent process will place two items on the table, and wake up the appropriate
smoker, and then go to sleep. All semaphores except lock are initialised to 0.
Lock is initialised to 1, and is a mutex variable.
Here’s the code for the agent process.
do forever {
P( lock ); 79
Introduction to Operating randNum = rand(1,3); // Pick a random number from 1-3
Systems and Process
Management if (randNum == 1) {
// Put tobacco on table
// Put paper on table
V(smoker_match); // Wake up smoker with match
}
else if (randNum == 2) {
// Put tobacco on table
// Put match on table
V(smoker_paper); // Wake up smoker with paper
}
else {
// Put match on table
// Put paper on table
V(smoker_tobacco);
} // Wake up smoker with tobacco
V(lock);
P(agent); // Agent sleeps
} // end forever loop
The following is the code for one of the smokers. The others are analogous.
do forever {
P(smoker_tobacco); // Sleep right away
P(lock);
// Pick up match
// Pick up paper
V(agent);
V(lock);
// Smoke
}
Structure
4.1 Introduction
4.2 Objectives
4.3 Deadlocks
4.4 Characterization of a Deadlock
4.4.1 Mutual Exclusion Condition
4.4.2 Hold and Wait Condition
4.4.3 No-Preemptive Condition
4.4.4 Circular Wait Condition
4.5 Resource Allocation Graph
4.6 Dealing with Deadlock Situations
4.6.1 Deadlock Prevention
4.6.2 Deadlock Avoidance
4.6.3 Deadlock Detection and Recovery
4.7 Summary
4.8 Solutions/Answers
4.9 Further Readings
4.1 INTRODUCTION
In a computer system, we have a finite number of resources to be distributed among a
number of competing processes. These system resources are classified in several types
which may be either physical or logical. Examples of physical resources are Printers,
Tape drivers, Memory space, and CPU cycles. Examples of logical resources are
Files, Semaphores and Monitors. Each resource type can have some identical instances.
A process must request a resource before using it and release the resource after using
it. It is clear that the number of resources requested cannot exceed the total number of
resources available in the system.
In a normal operation, a process may utilize a resource only in the following sequence:
Request: if the request cannot be immediately granted, then the requesting process
must wait until it can get the resource.
Use: the requesting process can operate on the resource.
Release: the process releases the resource after using it.
Examples for request and release of system resources are:
Request and release the device,
Opening and closing file,
Allocating and freeing the memory.
81
Introduction to Operating The operating system is responsible for making sure that the requesting process has
Systems and Process
Management been allocated the resource.Asystem table indicates if each resource is free or allocated,
and if allocated, to which process. If a process requests a resource that is currently
allocated to another process, it can be added to a queue of processes waiting for this
resource.
In some cases, several processes may compete for a fixed number of resources. A
process requests resources and if the resources are not available at that time, it enters
a wait state. It may happen that it will never gain access to the resources, since those
resources are being held by other waiting processes.
For example, assume a system with one tape drive and one plotter. Process P1 requests
the tape drive and process P2 requests the plotter. Both requests are granted. Now PI
requests the plotter (without giving up the tape drive) and P2 requests the tape drive
(without giving up the plotter). Neither request can be granted so both processes enter
a situation called the deadlock situation.
A deadlock is a situation where a group of processes is permanently blocked as a
result of each process having acquired a set of resources needed for its completion
and having to wait for the release of the remaining resources held by others thus making
it impossible for any of the deadlocked processes to proceed.
In the earlier units, we have gone through the concept of process and the need for the
interprocess communication and synchronization. In this unit we will study about the
deadlocks, its characterisation, deadlock avoidance and its recovery.
4.2 OBJECTIVES
After going through this unit, you should be able to:
define a deadlock;
understand the conditions for a deadlock;
know the ways of avoiding deadlocks, and
describe the ways to recover from the deadlock situation.
4.3 DEADLOCKS
Before studying about deadlocks, let us look at the various types of resources. There
are two types of resources namely: Pre-emptable and Non-pre-emptable Resources.
Pre-emptable resources: This resource can be taken away from the process
with no ill effects. Memory is an example of a pre-emptable resource.
Non-Preemptable resource: This resource cannot be taken away from the
process (without causing ill effect). For example, CD resources are not preemptable
at an arbitrary moment.
Reallocating resources can resolve deadlocks that involve preemptable resources.
Deadlocks that involve nonpreemptable resources are difficult to deal with. Let us see
how a deadlock occurs.
Definition: A set of processes is in a deadlock state if each process in the set is
82 waiting for an event that can be caused by only another process in the set. In other
words, each member of the set of deadlock processes is waiting for a resource that Deadlocks
can be released only by a deadlock process. None of the processes can run, none of
them can release any resources and none of them can be awakened. It is important to
note that the number of processes and the number and kind of resources possessed
and requested are unimportant.
Let us understand the deadlock situation with the help of examples.
Example 1: The simplest example of deadlock is where process 1 has been allocated
a non-shareable resource A, say, a tap drive, and process 2 has been allocated a non-
sharable resource B, say, a printer. Now, if it turns out that process 1 needs resource
B (printer) to proceed and process 2 needs resource A (the tape drive) to proceed and
these are the only two processes in the system, each has blocked the other and all
useful work in the system stops. This situation is termed as deadlock.
The system is in deadlock state because each process holds a resource being requested
by the other process and neither process is willing to release the resource it holds.
Example 2: Consider a system with three disk drives. Suppose there are three
processes, each is holding one of these three disk drives. If each process now requests
another disk drive, three processes will be in a deadlock state, because each process
is waiting for the event “disk drive is released”, which can only be caused by one of the
other waiting processes. Deadlock state involves processes competing not only for the
same resource type, but also for different resource types.
Deadlocks occur most commonly in multitasking and client/server environments and
are also known as a “Deadly Embrace”. Ideally, the programs that are deadlocked or
the operating system should resolve the deadlock, but this doesn’t always happen.
From the above examples, we have understood the concept of deadlocks. In the
examples we were given some instances, but we will study the necessary conditions
for a deadlock to occur, in the next section.
the printer resource might have two dots to indicate that we don’t really care which is
used, as long as we acquire the resource.
The edges among these nodes represent resource allocation and release. Edges are
directed, and if the edge goes from resource to process node that means the process
has acquired the resource. If the edge goes from process node to resource node that
means the process has requested the resource.
We can use these graphs to determine if a deadline has occurred or may occur. If for
example, all resources have only one instance (all resource node rectangles have one
dot) and the graph is circular, then a deadlock has occurred. If on the other hand some
resources have several instances, then a deadlock may occur. If the graph is not circular,
a deadlock cannot occur (the circular wait condition wouldn’t be satisfied).
The following are the tips which will help you to check the graph easily to predict the
presence of cycles.
If there is a cycle in the graph and each resource has only one instance, then there
is a deadlock. In this case, a cycle is a necessary and sufficient condition for
deadlock.
If there is a cycle in the graph, and each resource has more than one instance,
there may or may not be a deadlock. (A cycle may be broken if some process
outside the cycle has a resource instance that can break the cycle). Therefore, a
cycle in the resource allocation graph is a necessary but not sufficient condition for
deadlock, when multiple resource instances are considered.
Example:
85
Introduction to Operating
Introduction
and Process
Systems and
Management
Managem ent
The above graph shown in Figure 3 has a cycle and is not in Deadlock.
(Resource 1 has one instance shown by a star)
(Resource 2 has two instances a and b, shown as two stars)
R1 P1 P1 R2 (a)
R2 (b) P2 P2 R1
If P1 finishes, P2 can get R1 and finish, so there is no Deadlock.
Deadlock Prevention
Deadlock Avoidance
Let’s examine each strategy one by one to evaluate their respective strengths and
weaknesses.
Havender’s Algorithm
There are two possibilities for the elimination of the second condition. The first alternative
is that a process request be granted all the resources it needs at once, prior to execution.
The second alternative is to disallow a process from requesting resources whenever it
has previously allocated resources. This strategy requires that all the resources a process
will need must be requested at once. The system must grant resources on “all or
none” basis. If the complete set of resources needed by a process is not currently
available, then the process must wait until the complete set is available. While the
process waits, however, it may not hold any resources. Thus the “wait for” condition is
denied and deadlocks simply cannot occur. This strategy can lead to serious waste of
resources.
For example, a program requiring ten tap drives must request and receive all ten drives
before it begins executing. If the program needs only one tap drive to begin execution
and then does not need the remaining tap drives for several hours then substantial
computer resources (9 tape drives) will sit idle for several hours. This strategy can
cause indefinite postponement (starvation), since not all the required resources may
become available at once.
High Cost
When a process releases resources, the process may lose all its work to that point.
One serious consequence of this strategy is the possibility of indefinite postponement
(starvation).A process might be held off indefinitely as it repeatedly requests and
releases the same resources.
The last condition, the circular wait, can be denied by imposing a total ordering on all
of the resource types and than forcing all processes to request the resources in order
(increasing or decreasing). This strategy imposes a total ordering of all resource types,
and requires that each process requests resources in a numerical order of enumeration.
With this rule, the resource allocation graph can never have a cycle.
For example, provide a global numbering of all the resources, as shown in the given
Table 1:
87
Introduction to Operating Table 1: Numbering the resources
Systems and Process
Management
Number Resource
1 Floppy drive
2 Printer
3 Plotter
4 Tape Drive
5 CD Drive
The Banker’s Algorithm is based on the banking system, which never allocates its
available cash in such a manner that it can no longer satisfy the needs of all its customers.
Here we must have the advance knowledge of the maximum possible claims for each
process, which is limited by the resource availability. During the run of the system we
should keep monitoring the resource allocation status to ensure that no circular wait
condition can exist.
If the necessary conditions for a deadlock are in place, it is still possible to avoid
deadlock by being careful when resources are allocated. The following are the features
that are to be considered for avoidance of the deadlock s per the Banker’s Algorithms.
Each process declares maximum number of resources of each type that it may
need.
Keep the system in a safe state in which we can allocate resources to each process
in some order and avoid deadlock.
Check for the safe state by finding a safe sequence: <P1, P2, ..., Pn> where
resources that Pi needs can be satisfied by available resources plus resources held
by Pj where j < i.
88
Resource allocation graph algorithm uses claim edges to check for a safe state. Deadlocks
The resource allocation state is now defined by the number of available and allocated
resources, and the maximum demands of the processes. Subsequently the system can
be in either of the following states:
Safe state: Such a state occur when the system can allocate resources to each
process (up to its maximum) in some order and avoid a deadlock. This state will
be characterised by a safe sequence. It must be mentioned here that we should
not falsely conclude that all unsafe states are deadlocked although it may eventually
lead to a deadlock.
Unsafe State: If the system did not follow the safe sequence of resource allocation
from the beginning and it is now in a situation, which may lead to a deadlock, then
it is in an unsafe state.
Deadlock State: If the system has some circular wait condition existing for some
processes, then it is in deadlock state.
Let us study this concept with the help of an example as shown below:
Consider an analogy in which 4 processes (P1, P2, P3 and P4) can be compared with
the customers in a bank, resources such as printers etc. as cash available in the bank
and the Operating system as the Banker.
Table 2
Processes Resources Maximum
used resources
P1 0 6
P2 0 5
P3 0 4
P4 0 7
Available resource = 1
This is an unsafe state.
If all the processes request for their maximum resources respectively, then the operating
system could not satisfy any of them and we would have a deadlock.
Important Note: It is important to note that an unsafe state does not imply the existence
or even the eventual existence of a deadlock. What an unsafe state does imply is
simply that some unfortunate sequence of events might lead to a deadlock.
The Banker’s algorithm is thus used to consider each request as it occurs, and see if
granting it leads to a safe state. If it does, the request is granted, otherwise, it is postponed
until later. Haberman [1969] has shown that executing of the algorithm has a complexity
proportional to N2 where N is the number of processes and since the algorithm is
executed each time a resource request occurs, the overhead is significant.
Limitations of the Banker’s Algorithm
There are some problems with the Banker’s algorithm as given below:
It is time consuming to execute on the operation of every resource.
If the claim information is not accurate, system resources may be underutilized.
Another difficulty can occur when a system is heavily loaded. Lauesen states that
in this situation “so many resources are granted away that very few safe sequences
remain, and as a consequence, the jobs will be executed sequentially”. Therefore,
the Banker’s algorithm is referred to as the “Most Liberal” granting policy; that is,
it gives away everything that it can without regard to the consequences.
New processes arriving may cause a problem.
– The process’s claim must be less than the total number of units of the resource
in the system. If not, the process is not accepted by the manager.
90
– Since the state without the new process is safe, so is the state with the new Deadlocks
process. Just use the order you had originally and put the new process at the
end.
– Ensuring fairness (starvation freedom) needs a little more work, but isn’t too
hard either (once every hour stop taking new processes until all current
processes finish).
A resource becoming unavailable (e.g., a tape drive breaking), can result in an
unsafe state.
Check Your Progress 1
1) What is a deadlock and what are the four conditions that will create the deadlock
situation?
........................................................................................................................
........................................................................................................................
........................................................................................................................
........................................................................................................................
4.6 SUMMARY
A deadlock occurs a process has some resource and is waiting to acquire another
resource, while that resource is being held by some process that is waiting to acquire
the resource that is being held by the first process.
A deadlock needs four conditions to occur: Mutual Exclusion, Hold and Wait, Non-
Preemption and Circular Waiting.
We can handle deadlocks in three major ways: We can prevent them, handle them
when we detect them, or simply ignore the whole deadlock issue altogether.
4.7 SOLUTIONS/ANSWERS
Check Your Progress 1
1) A set of processes is in a deadlock state when every process in the set is waiting
for an event that can only be caused by another process in the set. A deadlock
situation can arise if the following four conditions hold simultaneously in a system:
92
Mutual Exclusion: At least one resource must be held in a non-shareable Deadlocks
mode; that is, only one process at a time can use the resource. If another
process requests the resource, the requesting process must be delayed until
the resource has been released.
Hold and Wait: A process must be holding at least one resource and waiting
to acquire additional resources that are currently being held by other
processes.
Circular Wait: A set {P0, P1, P2, …, Pn} of waiting processes must exist
such that P0 is waiting for a resource that is held by P1, P1 is waiting for a
resource that is held by P2, …, Pn-1 is waiting for a resource that is held by
Pn, and Pn is waiting for a resource that is held by P0.
2) Deadlock avoidance deals with processes that declare before execution how many
resources they may need during their execution. Given several processes and
resources, if we can allocate the resources in some order as to prevent a deadlock,
the system is said to be in a safe state. If a deadlock is possible, the system is said
to be in an unsafe state. The idea of avoiding a deadlock is to simply not allow the
system to enter an unsafe state which may cause a deadlock. We can define what
makes an unsafe state.
For example, consider a system with 12 tape drives and three processes: P0, P1
and P2. P0 may require 10 tape drives during execution, P1 may require 4, and
P2 may require up to 9. Suppose that at some moment in time, P0 is holding on to
5 tape drives, P1 holds 2 and P2 holds 2 tape drives. The system is said to be in
a safe state, since there is a safe sequence that avoids the deadlock. This sequence
implies that P1 can instantly get all of its needed resources (there are 12 total tape
drives, and P1 already has 2, so the maximum it needs is 2, which it can get since
there are 3 free tape drives). Once it finishes executing, it releases all 4 resources,
which makes for 5 free tape drives, at which point, P0 can execute (since the
maximum it needs is 10), after it finishes, P2 can proceed since the maximum it
needs is 9.
Now, here’s an unsafe sequence: Let’s say at some point of time P2 requests one
more resource to make its holding resources 3. Now the system is in an unsafe
state, since only P1 can be allocated resources, and after it returns, it will only
leave 4 free resources, which is not enough for either P0 or P2, so the system
enters a deadlock.
94
MCS--203
O
Operati
ing Systeems
In
ndira Gandhi
Naational Open University
U
Scchool of Compuuter and
In
nformation Scieences
Block
B
2
MEMORY
M Y MANA
AGEMEN NT, FILE
E
MANAGE
M EMENT AND
A SE
ECURITY Y
UNIT
U 1
Memory
M M
Managemen nt 5
UNIT
U 2
Virtual
V Meemory 23
UNIT
U 3
I//O and Fille Management 42
UNIT
U 4
Seecurity an
nd Protecttion 67
PROGRAMME/COURSE DESIGN COMMITTEE
Prof. Sanjeev K. Aggarwal, IIT, Kanpur Shri Sanjeev Thakur
Shri Navneet Aggarwal Amity School of Computer Sciences, Noida
Trinity BPM, New Delhi Shri Amrit Nath Thulal
Prof. M. Balakrishnan, IIT, Delhi Amity School of Engineering and Technology
Prof. Pandurangan, C., IIT, Madras New Delhi
Ms. Bhoomi Gupta Dr. Om Vikas(Retd), Ex-Sr. Director,
Sirifort College of Computer and Technology Ministry of ICT, Delhi
Management, New Delhi Shri Vishwakarma
Shri Manoj Kumar Gupta Amity School of Engineering and Technology
Keane India Ltd., New Delhi New Delhi
Shri Sachin Gupta Prof (Retd) S. K. Gupta, IIT Delhi
Delhi Institute of Advanced Studies, Prof. T.V. Vijaya Kumar, Dean, SC&SS,
New Delhi JNU, New Delhi
Prof. Harish Karnick, IIT, Kanpur Prof. Ela Kumar, Dean, CSE, IGDTUW, Delhi
Shri Anil Kumar
Prof. Gayatri Dhingra, GVMITM, Sonipat
Amity School of Engineering and Technology
New Delhi Sh. Milind Mahajani Vice President,
Dr. Kapil Kumar, IIMT, Meerut Impressico Business Solutions, Noida, UP
Dr. Sachin Kumar, Prof. V. V. Subrahmanyam, Director
SOCIS, New Delhi
CCS University,
Meerut Ms. Manjulata Prof. P. V. Suresh,
Amity School of Engineering and Technology SOCIS, IGNOU, New Delhi
New Delhi Dr. Shashi Bhushan
Shri Ajay Rana SOCIS, IGNOU, New Delhi
Amity School of Computer Sciences, Noida Shri Akshay Kumar, Associate Prof.
Dr. Divya Sharma SOCIS, IGNOU, New Delhi
Bharati College, Delhi Shri M. P. Mishra, Associate Prof.
Shri Neeraj Sharma SOCIS, IGNOU, New Delhi
Havard Institute of Management Technology Dr. Sudhansh Sharma, Asst. Prof
Noida SOCIS, IGNOU, New Delhi
PRINT PRODUCTION
Mr. Tilak Raj Mr. Yashpal
Asst. Registrar (Pub.) Section Officer (Pub.)
MPDD, IGNOU, New Delhi MPDD, IGNOU, New Delhi
March, 2021
© Indira Gandhi National Open University, 2021
All rights reserved. No part of this work may be reproduced in any form, by mimeograph or any other
means, without permission in writing from the Indira Gandhi National Open University.
Further information on the Indira Gandhi National Open University courses may be obtained from the
University’s office at Maidan Garhi, New Delhi-110068.
Printed and published on behalf of the Indira Gandhi National Open University, New Delhi by the
MPDD, IGNOU, New Delhi
Laser Typesetting : Akashdeep Printers, 20-Ansari Road, Daryaganj, New Delhi-110002
Printed at :
BLOCK INTRODUCTION
The objective of this block is to familiarize you with the issues involved in the
memory management, I/O management, File management and Security by the
Operating System.
The block is organized into 4 units.
Unit 1 covers the single process monitor, overlays, memory allocation methods,
paging and segmentation schemes.
Unit 2 covers the concept of virtual memory, demand paging, demand
segmentation and combined systems like segmented paging and paged
segmentation.
Unit 3 covers the I/O management and issues related to file management.
Unit 4 covers the very important and critical aspect namely security and protection.
Memory Management, File
Management and Security
4
Memory Management
UNIT 1 MEMORY MANAGEMENT
Structure
1.0 Introduction
1.1 Objectives
1.2 Overlays and Swapping
1.3 Logical and Physical Address Space
1.4 Single Process Monitor
1.5 Contiguous Allocation Methods
1.5.1 Single Partition System
1.5.2 Multiple Partition System
1.6 Paging
1.6.1 Principles of Operation
1.6.2 Page Allocation
1.6.3 Hardware Support for Paging
1.6.4 Protection and Sharing
1.7 Segmentation
1.7.1 Principles of Operation
1.7.2 Address Translation
1.7.3 Protection and Sharing
1.8 Summary
1.9 Solution/Answers
1.10 Further Readings
1.0 INTRODUCTION
In Block 1 we have studied about introductory concepts of the OS, process
management and deadlocks. In this unit, we will go through another important
function of the Operating System – the memory management.
Memory is central to the operation of a modern computer system. Memory is a
large array of words or bytes, each location with its own address. Interaction is
achieved through a sequence of reads/writes of specific memory address. The
CPU fetches from the program from the hard disk and stores in memory. If a
program is to be executed, it must be mapped to absolute addresses and loaded
into memory.
In a multiprogramming environment, in order to improve both the CPU utilization
and the speed of the computer’s response, several processes must be kept in
memory. There are many different algorithms depending 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: 5
Memory Management, File Keep track of which parts of memory are currently being used and by whom.
Management and Security
Decide which processes are to be loaded into memory when memory space
becomes available.
Allocate and deallocate memory space as needed.
In the multiprogramming environment operating system dynamically allocates
memory to multiple processes. Thus memory plays a significant role in the
important aspects of computer system like performance, S/W support, reliability
and stability.
Memory can be broadly classified into two categories–the primary memory (like
cache and RAM) and the secondary memory (like magnetic tape, disk etc.). The
memory is a resource that needs effective and efficient management. The part of
OS that perform this vital task of memory management is known as memory
manager. In multiprogramming system, as available memory is shared among
number of processes, so the allocation speed and the efficient memory utilization
(in terms of minimal overheads and reuse/relocation of released memory block)
are of prime concern. Protection is difficult to achieve with relocation requirement,
as location of process and absolute address in memory is unpredictable. But at
run-time, it can be done. Fortunately, we have mechanisms supporting protection
like processor (hardware) support that is able to abort the instructions violating
protection and trying to interrupt other processes.
This unit collectively depicts such memory management related responsibilities
in detail by the OS. Further we will discuss, the basic approaches of allocation
are of two types:
Contiguous Memory Allocation: Each programs data and instructions are
allocated a single contiguous space in memory.
Non-Contiguous Memory Allocation: Each programs data and instructions are
allocated memory space that is not continuous. This unit focuses on contiguous
memory allocation scheme.
1.1 OBJECTIVES
After going through this unit, you should be able to:
describe the various activities handled by the operating system while
performing the memory management function;
to allocate memory to the processes when they need it;
reallocation when processes are terminated;
logical and physical memory organization;
memory protection against unauthorized access and sharing;
to manage swapping between main memory and disk in case main storage is
small to hold all processes;
to summarize the principles of memory management as applied to paging
6 and segmentation;
compare and contrast paging and segmentation techniques, and Memory Management
Without
W the overlay
o it requires 180 K of memoryy and with thhe overlay support
s
memory
m requ
uirement is 1330K. Overlaay manager/ddriver is responsible for looading
and
a unloadinng on overlayy segment as per requireement. But thist scheme suffers
from
fr followinng limitationns:
Require careful
c and ttime-consum
ming planningg.
Programm mer is responnsible for orrganising oveerlay structuure of program m with
the help of
o file structuures etc. andd also to ensuure that piecee of code is already
a
loaded when
w it is callled.
Operatinng System proovides the faacility to loadd files into overlay
o region.
Swapping
S
Swapping
S is an approachh for memoryy managemeent by bringiing each process in
entirety,
e runn
ning it and thhen putting itt back on thee disk, so thaat another prrogram
may
m be loaded into that sppace. Swappiing is a technnique that letss you use a ddisk file
as
a an extensioon of memory ry. Lower priority user proocesses are swapped
s to backing
b
store (disk) when
w they are waiting for I/O
I or some oother event liike arrival off higher
priority
p proceesses. This is Rollout Swap
apping. Swappping the process back intto store
when
w some evvent occurs oor when needded (may be in i a differentt partition) is known
as
a Roll-in swa apping. Figuure 2 depicts technique off swapping:
8 Figuree 2: Swapping
Major benefits of using swapping are: Memory Management
Though swapping has these benefits but it has few limitations also like entire
program must be resident in store when it is executing. Also processes with
changing memory requirements will need to issue system calls for requesting
and releasing memory. It is necessary to know exactly how much memory a user
process is using and also that it is blocked or waiting for I/O.
As both the swap out and swap in should take place, the total swap time is then
about 220 milliseconds (above time is doubled). A round robin CPU scheduling
should have a time slot size much larger relative to swap time of 220 milliseconds.
Also if process is not utilising memory space and just waiting for I/O operation
or blocked, it should be swapped.
The
T entire seet of logicall addresses forms
f logicaal address sppace and sett of all
correspondin
c ng physical adddresses mak
akes physicall address spaace.
1
1.4 SING
GLE PR
ROCESS MONITOR
(MO
ONOPROOGRAMMMING)
In
n the simpleest case of sinngle-user sysstem everythhing was easy as at a tim
me there
was
w just one process in memory and no addresss translationn was done by the
operating
o sysstem dynamiically duringg execution. Protection
P o OS (or parrt of it)
of
can
c be achievved by keepiing it in ROM M.We can allso have a seeparate OS address
a
space only acccessible in supervisor
s mode
m as show
wn in Figure 4.
The
T user can employ oveerlays if mem mory requirem
ment by a prrogram exceeeds the
size of physical memory.. In this apprroach only one
o process at a time cann be in
ruunning statee in the systtem. Examplle of such ssystem is MS-DOS whicch is a
single tasking g system haaving a com mmand interppreter. Such an arrangem
ment is
liimited in cappability and pperformancee.
F
Figure 4: Sing
gle Partition System
S
1
1.5 CON
NTIGUO
OUS ALL
LOCATIO
ON MET
THODS
In
n a practical scenario Operating Systeem could be divided
d into several categgories
as
a shown in the
t hierarchiccal chart giv
ven below:
2)
2 Multiple process systeem with two types:
t Fixedd partition meemory and vaariable
partition memory.
10
Memory M
Management
Fu
urther we will learn thesee schemes inn next sectionn.
Pa
artitioned Memory
M allo
ocation:
Thhe concept of
o multiproggramming em
mphasizes onn maximizinng CPU utilizzation
byy overlapping CPU and I/O.
I Memory y may be alloocated as:
Single larg
ge partition for
f processes to use or
Multiple partitions
p wiith a single process
p usingg a single parrtition.
1..5.1 Single-Partition
n System
Thhis approach h keeps the Operating
O Syystem in the lower part of o the memorry and
otther user proocesses in thee upper part.. With this sccheme, Operrating System m can
bee protected from
fr updatingg in user proocesses. Reloocation-register scheme kknown
ass dynamic rellocation is usseful for this purpose. It nnot only proteects user proccesses
froom each othher but also from changging OS code and data. Two registeers are
ussed: relocatioon register, contains value of the smalllest physicall address andd limit
register, contaains logical adddresses rang ge. Both thesse are set by Operating Syystem
wh hen the job starts.
s At loadd time of proogram (i.e., when
w it has too be relocateed) we
must
m establishh “addressabbility” by adj djusting the rrelocation reegister conteents to
th
he new startin ng address foor the prograam. The scheeme is shown n in Figure 55.
Figure 5: Dyn
namic Relocattion
Thhe contents of
o a relocation
n register aree implicitly added
a to any address
a referrences
geenerated by the
t program. Some system ms use base registers as relocation
r reegister
fo
or easy addreessability as these are wiithin program mmer’s contrrol. Also, in some
sy
ystems, reloccation is man
naged and accessed by Opperating Sysstem only.
Too summarize this, we can say, in dynam mic relocatioon scheme if the t logical adddress
sp
pace range iss 0 to Max thent physicaal address sppace range is i R+0 to R+ +Max
(w
where R is rellocation regiister contentss). Similarly,, a limit regisster is checkeed by
11
Memory Management, File H/W
H to be suure that logiccal address generated
g by CPU is not bigger than size of
Mana
agement and Security
thhe program.
1
1.5.2 Multtiple Partiition Systeem: Fixed--sized parttition
This
T is also known
k as staatic partitionning schemee as shown inn Figure 6. S Simple
memory
m management scheme is to divvide memory into n (possiibly unequal)) fixed-
sized partitio
ons, each off which can hold exactlly one proceess. The deggree of
multiprogram
m mming is depeendent on thee number of ppartitions. IBM used this sscheme
for
fo systems 360
3 OS/MFT (Multipro ogramming w with a fixed number of tasks).
The
T partitionn boundaries are not movvable (must reboot to moove a job). We W can
have
h one queeue per partittion or just a single queuee for all the partitions.
p
F
Figure 6: Multtiple Partition System
Innitially, whoole memory iis available forf user proccesses and iss like a largee block
of
o available memory.
m Opeerating System keeps detaails of availaable memory blocks
and
a occupiedd blocks in tabbular form. OS O also keepss track on meemory requireements
of
o each proccess. As proccesses enter into the inpput queue annd when suffficient
space for it iss available, process is alloocated spacee and loaded. After its exeecution
iss over it releeases its occuupied space and
a OS fills this space with
w other proocesses
inn input queu ue. The blocck of availab ble memory is known ass a Hole. Hooles of
various
v sizes are scattered throughou ut the memory ry. When anyy process arrrives, it
iss allocated memory
m from
m a hole thaat is large ennough to acccommodate it. i This
example
e is shhown in Figuure 7:
acccommodate the allotted partition or partition rem mains unusedd, if it is too small
to hold any process
p fromm input queuue. Main meemory utilizaation is extreemely
nefficient. Anny program, no matter ho
in ow small, occcupies entirre partition. IIn our
exxample, proccess B takes 150K of parrtition2 (2000K size). Wee are left withh 50K
sizzed hole. Thiis phenomen non, in which there is wastted space inteernal to a parrtition,
is known as innternal fragm mentation. Itt occurs becaause initially
y process is looaded
n partition thaat is large en
in nough to holdd it (i.e., allocated memory may be sllightly
larrger than reqquested mem mory). “Internnal” here meeans memory y that is interrnal to
a partition,
p buut is not in usse.
1..5.3 Variable-sized d Partition
IB
BM used this technique fo or OS/MVT (Multiprogra
( amming with a Variable nuumber
off Tasks) as thee partitions are
a of variablee length and number. But still fragmenntation
an
nomaly existts in this schheme. As tim me goes on aand processees are loadeed and
removed from m memory, fraagmentation increases annd memory uttilization decclines.
Thhis wastage of memory, which is exxternal to paartition, is knownk as extternal
fraagmentationn. In this, thoough there iss enough totaal memory too satisfy a reequest
buut as it is no
ot contiguou us and it is fragmented
f into small ho
oles, that cann’t be
uttilized.
Exxternal fragm
mentation prooblem can bee resolved byy coalescing holes and storage
co
ompaction. Coalescing
C holes
h is proccess of merging existing hole adjacennt to a
w terminatee and free its allocated sppace. Thus, new
prrocess that will n adjacent holes
an
nd existing holes
h can bee viewed as a single largge hole and can be efficciently
uttilized.
Thhere is anothher possibiliity that holees are distribbuted throughhout the meemory.
Foor utilising such
s scattereed holes, shuuffle all occuupied areas of
o memory tto one
en
nd and leave all free mem mory space as a single large block, which
w can fu
further
bee utilized. This
T mechan nism is know wn as Storagge Compacttion, as show wn in
Fiigure 9.
13
Memory Management, File
agement and Security
Mana
But
B storage compaction
c aalso has its liimitations ass shown belo
ow:
1) It requirees extra overhheads in term
ms of resourcee utilization and
a large respponse
time.
2)
2 Compacttion is requiired frequenntly because jobs terminnate rapidly.. This
enhancess system resoource consum
mption and makes
m compaaction expennsive.
3)
3 Compacttion is possiible only if dynamic rellocation is being b used (aat run-
time). Thhis is becausee the memorry contents thhat are shufffled (i.e., reloocated)
and execuuted in new location requ uire all interrnal addressees to be reloccated.
Inn a multiprogramming syystem memo ory is dividedd into a nummber of fixed size or
variable
v sizedd partitions oor regions, which
w are alloocated to runnning processses. For
example:
e a prrocess needss m words off memory maay run in a partition
p of n words
where
w n is grreater than oor equal to m.m The variaable size parrtition schem me may
reesult in a situuation wheree available memory
m is nott contiguous, but fragmenntation
and
a external fragmentatio
f on. The differrence (n-m) iis called inteernal fragmenntation,
memory
m which is internaal to a partittion but is notn being usse. If a partiition is
unused
u and available,
a butt too small too be used byy any waiting g process, thhen it is
accounted
a forr external fraagmentation.. These mem mory fragmennts cannot be used.
In
n order to soolve this probblem, we cann either com
mpact the mem mory making large
free
fr memoryy blocks, or implement paging p scheeme which allows
a a program’s
memory
m to bee noncontiguuous, thus peermitting a prrogram to bee allocated phhysical
memory
m wherrever it is avvailable.
Check Your
Y Progresss 1
1) What aree the four impportant taskss of a memorry manager?
........................................................................................................................
........................................................................................................................
........................................................................................................................
........................................................................................................................
........................................................................................................................
2)
2 What aree the three triicks used to resolve
r absoolute addresses?
........................................................................................................................
........................................................................................................................
14
............................................................................................................................. Memory Management
.............................................................................................................................
.............................................................................................................................
1..6 PAG
GING
We
W will see thhe principles of operationn of the paginng in the nexxt section.
Paaging scheme solves the problem
p faced in variablle sized partiitions like exxternal
fraagmentationn.
1.6.3
1 Hard
dware Sup
pport for Paging
P
Every
E logicall page in pagging scheme is divided innto two partss:
1) A page number
n (p) inn logical addrress space
2)
2 The displlacement (orr offset) in paage p at whicch item residdes (i.e., from
m start
of page).
This
T is knownn as Addresss Translationn scheme. For example, a 16-bit addreess can
be
b divided ass given in Figgure below:
Here,
H as pagee number takees 5bits, so raange of valuees is 0 to 31(ii.e. 25-1). Sim
milarly,
offset
o value uses
u 11-bits, so range is 0 to 2023(i.ee., 2 –1). Suummarizing this
11
t we
can
c say pagin ng scheme usses 32 pages, each with 22024 locationns.
The
T table, wh hich holds virrtual address to physical aaddress transllations, is callled the
page
p table. As
A displacemeent is constan nt, so only traanslation of virtual
v page number
n
too physical paage is requireed. This can be
b seen diagrrammaticallyy in Figure 111.
adddress of each corresponding physiical memoryy page numb ber (Frame).. This
reeduces dynammic relocatiion efforts. The Pagingg hardware support
s is shown
s
diiagrammaticaally in Figurre 12:
Figu
ure 12: Direct Mapping
Pa
aging addreess Translatiion by direcct mapping
Thhis is the casee of direct mapping as paage table sendds directly too physical meemory
paage. This is shown
s in Fig
gure 12. But disadvantaage of this sccheme is its speed
off translation.. This is becaause page taable is kept iin primary sttorage and itts size
caan be considderably largge which inccreases instrruction execcution time (also
acccess time) and
a hence decreases
d sysstem speed. To overcom me this addittional
haardware suppport of regiisters and buffers can bbe used. Thiis is explainned in
neext section.
Pa
aging Addreess Translattion with Associative M
Mapping
Th his scheme is based on n the use of dedicated rregisters with h high speed and
effficiency. Theese small, faast-lookup caache help to pplace the enttire page tablle into
a content-addr
c resses associiative storagee, hence speeed-up the loo okup problem m with
a cache.
c Thesee are known asa associativee registers or Translation Look-aside
L B
Buffers
(T
TLB’s). Eachh register connsists of two entries:
It is similar too direct mappping schemee but here as TLB’s contaain only few w page
tabble entries, so
s search is fast. But it isi quite expeensive due to o register suppport.
Soo, both direcct and associiative mappiing schemess can also bee combined to get
more
m benefitss. Here, pag ge number is i matched w with all associative reggisters
sim
multaneouslyy. The perceentage of thhe number oof times the page is fouund in
TLLB’s is calleed hit ratio. If it is not fou
und, it is searrched in pagge table and added
a
in
nto TLB. Buut if TLB is already fulll then page replacemennt policies can be
ussed. Entries in TLB cann be limited only. This ccombined schheme is shown in
Fiigure 13.
17
Memory Management, File
agement and Seeccurity
Mana urity
1.6.4
1 Prottection and
d Sharing
Paging
P hardwware typically also conttains some pprotection mechanism.
m Inn page
taable corresponding to eaach frame a protection
p biit is associateed. This bit can
c tell
iff page is readd-only or reaad-write. Shaaring code aand data takees place if tw wo page
taable entries in different processes point
p to samee physical page,
p the proocesses
share the mem mory. If one pprocess writes the data, othher process will
w see the chhanges.
Itt is a very efficient
e wayy to communnicate. Shariing must alsso be controolled to
protect
p modification and accessing data d in one process by annother process. For
thhis programss are kept seeparately as procedures
p aand data, where procedurres and
data
d that are non-modifia
n able (pure/reeentrant code)) can be sharred. Reentrannt code
cannot
c modiffy itself and mmust make suure that it hass a separate copy
c of per-pprocess
global
g variabbles. Modifiiable data and a proceduures cannot be b shared w without
concurrency
c controls. NNon-modifiaable proceduures are alsso known as a pure
procedures
p orr reentrant coodes (can’t chhange duringg execution). For examplle, only
one
o copy of editor or coompiler codee can be keppt in memoryy, and all edditor or
compiler
c proccesses can exxecute that single
s copy oof the code. This
T helps memory
m
utilization.
u Major
M advantaages of pagin ng scheme arre:
1) Virtual adddress space must be greaater than maiin memory siize.i.e., can execute
e
program with large loogical addresss space as ccompared witth physical address
a
space.
2)
2 Avoid exxternal fragm
mentation and
d hence storaage compactiion.
3)
3 Full utilizzation of avaailable main storage.
Disadvantag
D ges of pagingg include intternal fragm
mentation prooblem i.e., wastage
w
within
w allocaated page whhen process is smaller thhan page bouundary. Alsoo, extra
reesource conssumption and overheads for paging hardware
h andd virtual adddress to
physical
p addrress translation takes placce.
1.7
1 SEG
GMENTA
ATION
In
n the earlierr section we have seen th
he memory management
m t scheme called as
18 paging.
p
In
n general, a user or a proggrammer preffers to view ssystem memory as a colleection Memory M
Management
off variable-sizzed segmentss rather thann as a linear array of worrds. Segmenntation
is a memory management
m scheme thatt supports thiis view of memory.
m
Figure 14: Ad
ddress Translaation
Check Your Progress 2
1) What is the advantage of using Base and Limit registers?
........................................................................................................................
........................................................................................................................
........................................................................................................................
........................................................................................................................
........................................................................................................................
........................................................................................................................
........................................................................................................................
........................................................................................................................
4) A system with 18-bit address uses 6 bits for page number and next 12 bits for
offset. Compute the total number of pages and express the following address
according to paging scheme 001011(page number) and 000000111000
(offset)?
........................................................................................................................
........................................................................................................................
........................................................................................................................
........................................................................................................................
........................................................................................................................
........................................................................................................................
1.8 SUMMARY
In this unit, we have learnt how memory resource is managed and how processes
are protected from each other. The previous two sections covered memory
allocation techniques like swapping and overlays, which tackle the utilization of
memory. Paging and segmentation was presented as memory management
schemes. Both have their own merits and demerits. We have also seen how paging
is based on physical form of process and is independent of the programming
structures, while segmentation is dependent on logical structure of process as
viewed by user. We have also considered fragmentation (internal and external)
problems and ways to tackle them to increase level of multiprogramming and
system efficiency. Concept of relocation and compaction helps to overcome
external fragmentation.
22
Virtual Memory
UNIT 2 VIRTUAL MEMORY
Structure
2.0 Introduction
2.1 Objectives
2.2 Virtual Memory
2.2.1 Principles of Operation
2.2.2 Virtual Memory Management
2.2.3 Protection and Sharing
2.3 Demand Paging
2.4 Page Replacement Policies
2.4.1 First In First Out (FIFO)
2.4.2 Second Chance (SC)
2.4.3 Least Recently Used (LRU)
2.4.4 Optimal Algorithm (OPT)
2.4.5 Least Frequently Used (LFU)
2.5 Thrashing
2.5.1 Working-Set Model
2.5.2 Page-Fault Rate
2.6 Demand Segmentation
2.7 Combined Systems
2.7.1 Segmented Paging
2.7.2 Paged Segmentation
2.8 Summary
2.9 Solutions/Answers
2.10 Further Readings
2.0 INTRODUCTION
In the earlier unit, we have studied Memory Management covering topics like
the overlays, contiguous memory allocation, static and dynamic partitioned
memory allocation, paging and segmentation techniques. In this unit, we will
study an important aspect of memory management known as Virtual memory.
Storage allocation has always been an important consideration in computer
programming due to the high cost of the main memory and the relative abundance
and lower cost of secondary storage. Program code and data required for execution
of a process must reside in the main memory but the main memory may not be
large enough to accommodate the needs of an entire process. Early computer
programmers divided programs into the sections that were transferred into the
main memory for the period of processing time. As the program proceeded, new
sections moved into the main memory and replaced sections that were not needed
at that time. In this early era of computing, the programmer was responsible for
devising this overlay system. 23
Memory Management, File As higher-level languages became popular for writing more complex programs
Management and Security
and the programmer became less familiar with the machine, the efficiency of
complex programs suffered from poor overlay systems. The problem of storage
allocation became more complex.
Two theories for solving the problem of inefficient memory management emerged
— static and dynamic allocation. Static allocation assumes that the availability
of memory resources and the memory reference string of a program can be
predicted. Dynamic allocation relies on memory usage increasing and decreasing
with actual program needs, not on predicting memory needs.
Program objectives and machine advancements in the 1960s made the predictions
required for static allocation difficult, if not impossible. Therefore, the dynamic
allocation solution was generally accepted, but opinions about implementation
were still divided. One group believed the programmer should continue to be
responsible for storage allocation, which would be accomplished by system calls
to allocate or deal locate memory. The second group supported automatic storage
allocation performed by the operating system, because of increasing complexity
of storage allocation and emerging importance of multiprogramming. In 1961,
two groups proposed a one-level memory store. One proposal called for a very
large main memory to alleviate any need for storage allocation. This solution
was not possible due to its very high cost. The second proposal is known as
virtual memory.
In this unit, we will go through virtual memory and related topics.
2.1 OBJECTIVES
After going through this unit, you should be able to:
discuss why virtual memory is needed;
define virtual memory and its underlying concepts;
describe the page replacement policies like Optimal, FIFO and LRU;
discuss the concept of thrashing, and
explain the need of the combined systems like Segmented paging and Paged
segmentation.
has been known since the 1960s but has become common on computer systems
since the late 1980s. The virtual memory scheme divides physical memory into
blocks and allocates blocks to different processes. Of course, in order to do this
sensibly it is highly desirable to have a protection scheme that restricts a process
to be able to access only those blocks that are assigned to it. Such a protection
scheme is thus a necessary, and somewhat involved, aspect of any virtual memory
implementation.
One other advantage of using virtual memory that may not be immediately
apparent is that it often reduces the time taken to launch a program, since not all
the program code and data need to be in physical memory before the program
execution can be started.
Although sharing the physical address space is a desirable end, it was not the
sole reason that virtual memory became common on contemporary systems. Until
the late 1980s, if a program became too large to fit in one piece in physical
memory, it was the programmer’s job to see that it fit. Programmers typically did
this by breaking programs into pieces, each of which was mutually exclusive in
its logic. When a program was launched, a main piece that initiated the execution
would first be loaded into physical memory, and then the other parts, called
overlays, would be loaded as needed.
It was the programmer’s task to ensure that the program never tried to access
more physical memory than was available on the machine, and also to ensure
that the proper overlay was loaded into physical memory whenever required.
These responsibilities made for complex challenges for programmers, who had
to be able to divide their programs into logically separate fragments, and specify
a proper scheme to load the right fragment at the right time. Virtual memory
came about as a means to relieve programmers creating large pieces of software
of the wearisome burden of designing overlays.
Virtual memory automatically manages two levels of the memory hierarchy,
representing the main memory and the secondary storage, in a manner that is
invisible to the program that is running. The program itself never has to bother
with the physical location of any fragment of the virtual address space. A
mechanism called relocation allows for the same program to run in any location
in physical memory, as well. Prior to the use of virtual memory, it was common
for machines to include a relocation register just for that purpose. An expensive
and messy solution to the hardware solution of a virtual memory would be software
that changed all addresses in a program each time it was run. Such a solution
would increase the running times of programs significantly, among other things.
Virtual memory enables a program to ignore the physical location of any desired
block of its address space; a process can simply seek to access any block of its
address space without concern for where that block might be located. If the block
happens to be located in the main memory, access is carried out smoothly and
quickly; else, the virtual memory has to bring the block in from secondary storage
and allow it to be accessed by the program.
The technique of virtual memory is similar to a degree with the use of processor
caches. However, the differences lie in the block size of virtual memory being 25
Memory Management, File typically much larger (64 kilobytes and up) as compared with the typical processor
Management and Security
cache (128 bytes and up). The hit time, the miss penalty (the time taken to retrieve
an item that is not in the cache or primary storage), and the transfer time are all
larger in case of virtual memory. However, the miss rate is typically much smaller.
(This is no accident-since a secondary storage device, typically a magnetic storage
device with much lower access speeds, has to be read in case of a miss, designers
of virtual memory make every effort to reduce the miss rate to a level even much
lower than that allowed in processor caches).
Virtual memory systems are of two basic kinds—those using fixed-size blocks
called pages, and those that use variable-sized blocks called segments.
Suppose, for example, that a main memory of 64 megabytes is required but only
32 megabytes is actually available. To create the illusion of the larger memory
space, the memory manager would divide the required space into units called
pages and store the contents of these pages in mass storage. A typical page size is
no more than four kilobytes. As different pages are actually required in main
memory, the memory manager would exchange them for pages that are no longer
required, and thus the other software units could execute as though there were
actually 64 megabytes of main memory in the machine.
In brief we can say that virtual memory is a technique that allows the execution
of processes that may not be completely in memory. One major advantage of this
scheme is that the program can be larger than physical memory. Virtual memory
can be implemented via demand paging and demand segmentation.
Figure 1:
1 Abstract mo
odel of Virtuall to Physical address
a mappiing
In
n a virtual memory system m all of thesse addressess are virtual addresses annd not
phhysical addreesses. These virtual addreesses are connverted into physical
p addrresses
byy the processsor based onn informationn held in a set of tables maintained
m bby the
opperating system.
Too make this translation easier, virtual and physiical memoryy are dividedd into
sm
mall blocks called pages. These pagess are all of thee same size. (It
( is not neceessary
th
hat all the pag
ges should be
b of same siize but if theey were not, the system would
w
bee very hard to administerr). Linux on Alpha AXP systems uses 8 Kbytes ppages 27
Memory Management, File and on Intel x86 systems it uses 4 Kbytes pages. Each of these pages is given a
Management and Security
unique number; the page frame number (PFN) as shown in the Figure 1.
In this paged model, a virtual address is composed of two parts, an offset and a
virtual page frame number. If the page size is 4 Kbytes, bits 11:0 of the virtual
address contain the offset and bits 12 and above are the virtual page frame number.
Each time the processor encounters a virtual address it must extract the offset
and the virtual page frame number. The processor must translate the virtual page
frame number into a physical one and then access the location at the correct
offset into that physical page. To do this the processor uses page tables.
The Figure1 shows the virtual address spaces of two processes, process X and
process Y, each with their own page tables. These page tables map each processes
virtual pages into physical pages in memory. This shows that process X’s virtual
page frame number 0 is mapped into memory in physical page frame number 1
and that process Y’s virtual page frame number 1 is mapped into physical page
frame number 4. Each entry in the theoretical page table contains the following
information:
Valid flag : This indicates if this page table entry is valid.
PFN : The physical page frame number that this entry is describing.
Access control information : This describes how the page may be used. Can
it be written to? Does it contain executable code?
The page table is accessed using the virtual page frame number as an offset.
Virtual page frame 5 would be the 6th element of the table (0 is the first element).
To translate a virtual address into a physical one, the processor must first work
out the virtual addresses page frame number and the offset within that virtual
page. By making the page size a power of 2 this can be easily done by masking
and shifting. Looking again at the Figure1 and assuming a page size of 0x2000
bytes (which is decimal 8192) and an address of 0x2194 in process Y’s virtual
address space then the processor would translate that address into offset 0x194
into virtual page frame number 1.
The processor uses the virtual page frame number as an index into the processes
page table to retrieve its page table entry. If the page table entry at that offset is
valid, the processor takes the physical page frame number from this entry. If the
entry is invalid, the process has accessed a non-existent area of its virtual memory.
In this case, the processor cannot resolve the address and must pass control to the
operating system so that it can fix things up.
Just how the processor notifies the operating system that the correct process has
attempted to access a virtual address for which there is no valid translation is
specific to the processor. However, the processor delivers it, this is known as a
page fault and the operating system is notified of the faulting virtual address and
the reason for the page fault. A page fault is serviced in a number of steps:
i) Trap to the OS.
ii) Save registers and process state for the current process.
iii) Check if the trap was caused because of a page fault and whether the page
28 reference is legal.
ivv) If yes, dettermine the lo
ocation of thhe required page
p on the backing
b storee. Virtu
ual Memory
Only
O one coppy of the ediitor needs to be stored inn the physicaal memory. IIn each
page
p he included editor page is mapped oonto the sam
table, th me physical copy
c of
thhe editor, bu
ut the data pages are mappped onto diffferent framess. So, to suppport 40
users,
u we onlly need one copy of the editor, i.e., 330 KB, plus 40 copies oof the 5
KB
K of data pagesp per user; the total required space is now 230
2 KB insttead of
1400 KB.
Other
O heavilyy used prograams such as assembler, compiler,
c dattabase system ms etc.
can
c also be shared
s amonng different users.
u The oonly conditioon for it is thhat the
code
c must bee reentrant. Itt is crucial too correct thee functionalitty of shared paging
scheme so that the pages are unchangged. If one uuser wants to change a location,
itt would be ch
hanged for aall other userrs.
Fig
gure 3: Pagingg scheme supp
porting the shaaring of progrram code
2.3
2 DEM
MAND PA
AGING
In
n a multiprogramming syystem memo ory is dividedd into a numb ber of fixed--size or
variable-sized
v d partitions or regions th hat are alloccated to runnning processees. For
example:
e a prrocess needss m words off memory maay run in a partition
p of n words
where
w n m. The variablle size partittion scheme may result inn a situationn where
available
a memmory is not ccontiguous, but
b fragmentted into manny scattered blocks.
b
We
W distinguissh between innternal fragm mentation annd external fragmentatio
f on. The
difference
d (n – m) is callled internal fragmentatio
f on, memory thatt is internnal to a
partition
p but is not beingg used. If a partition is unused and d available, but
b too
small to be used
u by anyy waiting prrocess, then it is accoun nted for extternal
fragmentation
fr n. These mem mory fragmeents cannot bbe used.
30
In order to solve this problem, we can either compact the memory making large Virtual Memory
free memory blocks, or implement paging scheme which allows a program’s
memory to be non-contiguous, thus permitting a program to be allocated to
physical memory.
Physical memory is divided into fixed size blocks called frames. Logical memory
is also divided into blocks of the same, fixed size called pages. When a program
is to be executed, its pages are loaded into any available memory frames from
the disk. The disk is also divided into fixed sized blocks that are the same size as
the memory frames.
A very important aspect of paging is the clear separation between the user’s view
of memory and the actual physical memory. Normally, a user believes that memory
is one contiguous space containing only his/her program. In fact, the logical
memory is scattered through the physical memory that also contains other
programs. Thus, the user can work correctly with his/her own view of memory
because of the address translation or address mapping. The address mapping,
which is controlled by the operating system and transparent to users, translates
logical memory addresses into physical addresses.
Because the operating system is managing the memory, it must be sure about the
nature of physical memory, for example: which frames are available, which are
allocated; how many total frames there are, and so on. All these parameters are
kept in a data structure called frame table that has one entry for each physical
frame of memory indicating whether it is free or allocated, and if allocated, to
which page of which process.
As there is much less physical memory than virtual memory the operating system
must be careful that it does not use the physical memory inefficiently. One way
to save physical memory is to load only virtual pages that are currently being
used by the executing program. For example, a database program may be run to
query a database. In this case not the entire database needs to be loaded into
memory, just those data records that are being examined. Also, if the database
query is a search query then it is not necessary to load the code from the database
that deals with adding new records. This technique of only loading virtual pages
into memory as they are accessed is known as demand paging.
When a process attempts to access a virtual address that is not currently in memory
the CPU cannot find a page table entry for the virtual page referenced. For example,
in Figure 1, there is no entry in Process X’s page table for virtual PFN 2 and so
if Process X attempts to read from an address within virtual PFN 2 the CPU
cannot translate the address into a physical one. At this point the CPU cannot
cope and needs the operating system to fix things up. It notifies the operating
system that a page fault has occurred and the operating system makes the process
wait whilst it fixes things up. The CPU must bring the appropriate page into
memory from the image on disk. Disk access takes a long time, and so the process
must wait quite a while until the page has been fetched. If there are other processes
that could run then the operating system will select one of them to run. The
fetched page is written into a free physical page frame and an entry for the virtual
PFN is added to the processes page table. The process is then restarted at the
point where the memory fault occurred. This time the virtual memory access is
made, the CPU can make the address translation and so the process continues to
31
Memory Management, File run. This is known as demand paging and occurs when the system is busy but
Management and Security
also when an image is first loaded into memory. This mechanism means that a
process can execute an image that only partially resides in physical memory at
any one time.
The valid/invalid bit of the page table entry for a page, which is swapped in, is
set as valid. Otherwise it is set as invalid, which will have no effect as long as the
program never attempts to access this page. If all and only those pages actually
needed are swapped in, the process will execute exactly as if all pages were
brought in.
If the process tries to access a page, which was not swapped in, i.e., the valid/
invalid bit of this page table, entry is set to invalid, then a page fault trap will
occur. Instead of showing the “invalid address error” as usually, it indicates the
operating system’s failure to bring a valid part of the program into memory at the
right time in order to minimize swapping overhead.
There are many approaches to the problem of deciding which page is to replace
but the object is the same for all-the policy that selects the page that will not be
referenced again for the longest time. A few page replacement policies are
described below.
2..4.2 Secon
nd Chancee (SC)
Th he Second Chance
C (SC)) policy is a slight moddification of FIFO in ordder to
avvoid the probblem of replaacing a heaviily used pagee. In this poliicy, a referennce bit
R is used to keeep track of pages
p that haave been receently referen nced. This bitt is set
to 1 each time the page is referenced.
r P
Periodically, all the refereence bits aree set to
0 by the operrating system m to distinguuish pages thhat have not been referrenced
reecently from
m those that have been. Using this bit, b the operrating system m can
deetermine wheether old pagges are still being used (i.e.,
( R = 1).. If so, the page is
moved
m to the end
e of the lisst of pages, annd its load tiime is updateed as though it had
ju
ust arrived in
n memory. Th hen the searcch continues. Thus heaviily accessed pages
arre given a “seecond chance.”
2..4.4 Optim
mal Algoriithm (OPT
T)
Opptimal algorrithm is defined as replaace the pagee that will noot be used fo
for the
longest periodd of time. It
I is optimall in the perfformance buut not feasibble to
im
mplement beccause we can nnot predict future time.
Exxample:
Leet us consideer a 4 framess example
1, 2, 3, 4, 1, 2, 5, 1, 2,, 3, 4, 5
In
n the above Figure,
F we haave 6 page faaults.
2.5 THRASHING
Thrashing occurs when a system spends more time processing page faults than
executing transactions. While processing page faults it is necessary to be in order
to appreciate the benefits of virtual memory, thrashing has a negative effect on
the system.
As the page fault rate increases, more transactions need processing from the
paging device. The queue at the paging device increases, resulting in increased
service time for a page fault. While the transactions in the system are waiting for
the paging device, CPU utilization, system throughput and system response time
decrease, resulting in below optimal performance of a system.
Thrashing becomes a greater threat as the degree of multiprogramming of the
system increases.
2.5.2
2 Pagee-Fault Raate
The
T workingg-set model is i successful, and knowleedge of the working w set can be
useful
u for pree-paging, butt it is a scatteered way to control thrasshing. A pagge-fault
frequency
fr (page-fault ratte) takes a more
m direct approach. Inn this we esstablish
upper
u and lowwer bound onn the desired d page- fault rate.
r If the acctual page fauult rate
exceeds
e the upper
u limit, w
we allocate thet process aanother fram me. If the pagge fault
raate falls beloow the lowerr limit, we reemove a Fram me from thee process. Thhus, we
can
c directly measure
m and control the page
p fault raate to preventt thrashing.
Establish
E “accceptable” paage-fault ratee.
If actual rate
r too low,, process loses frame.
If actual rate
r too highh, process gaains frame.
2.6
2 DEM
MAND SEGMEN
NTATION
N
Segmentatio
S on
Programs
P gennerally dividde up their memory
m usagge by functiion. Some memory
m
holds
h instrucctions, somee static data, some dynaamically allocated data,, some
execution
e fraames. All of these memoory types havve different protection,
p g
growth,
and
a sharing requirementss. In the monolithic memoory allocatioon of classic Virtual
V
Memory
M systtems, this moodel isn’t weell supported.
Segmentation
S n addresses thhis by providding multiplee sharable, prootectable, groowable
address
a spacees that proceesses can acccess.
In
n pure segmeentation archhitecture, seg
gments are alllocated like variable parttitions,
although
a the memory maanagement haardware is innvolved in decoding
d adddresses.
Pure
P segmenntation addreesses replacee the page iddentifier in the
t virtual address
a
with
w a segmeent identifierr, and find the t proper seegment (not page) to whhich to
apply
a the offsset.
36
The segment table is managed like the page table, except that segments explicitly Virtual Memory
allow sharing. Protections reside in the segment descriptors, and can use keying
or explicit access control lists to apply them.
Of course, the segment name space must be carefully managed, and thus OS
must provide a method of doing this. The file system can come to the rescue
here-a process can ask for a file to be mapped into a segment and have the OS
return the segment register to use. This is known as memory mapping files. It is
slightly different from memory mapping devices, because one file system
abstraction (a segment) is providing an interface to another (a file). Memory
mapped files may be reflected into the file system or not and may be shared or
not at the process’s discretion.
The biggest problem with segmentation is the same as with variable sized real
memory allocation: managing variable sized partitions can be very inefficient,
especially when the segments are large compared to physical memory. External
fragmentation can easily result in expensive compaction when a large segment is
loaded, and swapping large segments (even when compaction is not required)
can be costly.
Demand Segmentation
Same idea as demand paging applied to segments.
If a segment is loaded, base and limit are stored in the Segment Table Entry
(STE) and the valid bit is set in the Page Table Entry (PTE). The PTE is accessed
for each memory reference. If the segment is not loaded, the valid bit is unset.
The base and limit as well as the disk address of the segment is stored in the OS
table. R eference to a non-loaded segment generates a segment fault (analogous
to page fault). To load a segment, we must solve both the placement question
and the replacement question (for demand paging, there is no placement
question).
Paged Segmentation
1) What are the steps that are followed by the Operating system in order to
handle the page fault?
........................................................................................................................
........................................................................................................................
i) A Page Fault
ii) Thrashing
........................................................................................................................
........................................................................................................................
........................................................................................................................
........................................................................................................................
6) What is a working set and what happens when the working set is very different
from the set of pages that are physically resident in memory?
........................................................................................................................
........................................................................................................................
2.8 SUMMARY
With previous schemes, all the code and data of a program have to be in main
memory when the program is running. With virtual memory, only some of the
code and data have to be in main memory: the parts needed by the program now.
The other parts are loaded into memory when the program needs them without
the program having to be aware of this. The size of a program (including its data)
can thus exceed the amount of available main memory.
There are two main approaches to virtual memory: paging and segmentation.
Both approaches rely on the separation of the concepts virtual address and physical
address. Addresses generated by programs are virtual addresses. The actual
memory cells have physical addresses. A piece of hardware called a memory 39
Memory Management, File management unit (MMU) translates virtual addresses to physical addresses at
Management and Security
run-time.
In this unit we have discussed the concept of Virtual memory, its advantages,
demand paging, demand segmentation, Page replacement algorithms and
combined systems.
41
Memory Management, File
Management and Security UNIT 3 I/O AND FILE MANAGEMENT
Structure
3.0 Introduction
3.1 Objectives
3.2 Organisation of the I/O Function
3.3 I/O Buffering
3.4 Disk Organisation
3.4.1 Device Drivers and IDs
3.4.2 Checking Data Consistency and Formatting
3.5 Disk Scheduling
3.5.1 FCFS Scheduling
3.5.2 SSTF Scheduling
3.5.3 SCAN Scheduling
3.5.4 C-SCAN Scheduling
3.5.5 LOOK and C-LOOK Scheduling
3.6 RAID
3.7 Disk Cache
3.8 Command Language User’s View of the File System
3.9 The System Programmer’s View of the File System
3.10 The Operating System’s View of File Management
3.10.1 Directories
3.10.2 Disk Space Management
3.10.3 Disk Address Translation
3.10.4 File Related System Services
3.10.5 Asynchronous Input/Output
3.11 Summary
3.12 Solutions /Answers
3.13 Further Readings
3.0 INTRODUCTION
Input and output devices are components that form part of the computer system.
These devices are controlled by the operating system. Input devices such as
keyboard, mouse, and sensors provide input signals such as commands to the
operating system. These commands received from input devices instruct the
operating system to perform some task or control its behaviour. Output devices
such as monitors, printers and speakers are the devices that receive commands or
information from the operating system.
In the earlier unit, we had studied the memory management of primary memory.
The physical memory, as we have already seen, is not large enough to
42 accommodate all of the needs of a computer system. Also, it is not permanent.
Secondary storage consists of disk units and tape drives onto which data can be I/O and File Management
moved for permanent storage. Though there are actual physical differences
between tapes and disks, the principles involved in controlling them are the same,
so we shall only consider disk management here in this unit.
The operating system implements the abstract concept of the file by managing
mass storage devices, such as types and disks. 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.
Definition: 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.
File management is one of the most visible services of an operating system.
Computers can store information in several different physical forms among which
magnetic tape, disk, and drum are the most common forms. Each of these devices
has their own characteristics and physical organization.
Normally files are organized into directories to ease their use. 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 with file management:
The creation and deletion of files.
The creation and deletion of directory.
The support of primitives for manipulating files and directories.
The mapping of files onto disk storage.
Backup of files on stable (non volatile) storage.
The most significant problem in I/O system is the speed mismatch between I/O
devices and the memory and also with the processor. This is because I/O system
involves both H/W and S/W support and there is large variation in the nature of
I/O devices, so they cannot compete with the speed of the processor and memory.
A well-designed file management structure makes the file access quick and easily
movable to a new machine. Also it facilitates sharing of files and protection of
non-public files. For security and privacy, file system may also provide encryption
and decryption capabilities. This makes information accessible to the intended
user only.
In this unit we will study the I/O and the file management techniques used by the
operating system in order to manage them efficiently.
3.1 OBJECTIVES
After going through this unit, you should be able to: 43
Memory Management, File describe the management of the I/O activities independently and
Management and Security
simultaneously with processor activities;
summarize the full range of views that support file systems, especially the
operating system view;
compare and contrast different approaches to file organisations;
discuss the disk scheduling techniques, and
know how to implement the file system and its protection against unauthorized
usage.
Figure 1: Unb
buffered Transsfers
In
n case of sinngle-bufferedd transfer, bllocks are firsst read into a buffer andd then
moved
m to the user’s workk area. Whenn the move is i complete, the next bloock is
read into the buffer
b and prrocessed in parallel
p withh the first bloock. This heelps in
minimizing
m sppeed mismatcch between devices
d and tthe processorr. Also, this aallows
prrocess compuutation in paarallel with innput/output as
a shown in Figure
F 2.
Figure 2: Single
S Bufferin
ng
3..4 DISK
K ORGAN
NISATIO
ON
Disks come inn different sh
hapes and sizes. The mostt obvious disstinction betwween
oppy disks, diskettes
flo d andd hard disks is: floppy disks and diskkettes consistt, of a 45
Memory Management, File single disk of
o magnetic m material, whhile hard-disks normallyy consist of several
s
Mana
agement and Security
stacked on toop of one anoother. Hard disks
d are totaally enclosedd devices whhich are
much
m more fiinely engineered and theerefore requirre protection n from dust. A hard
disk
d spins at a constant sppeed, while the t rotation of o floppy driives is switched on
and
a off. On thhe Macintoshh machine, flo oppy drives have
h a variab
ble speed opeeration,
whereas
w most floppy drivves have onlyy a single sppeed of rotatiion. As hardd drives
and
a tape unitts become morem efficiennt and cheapper to produuce, the role of the
floppy
fl disk iss diminishingg. We look thherefore maiinly at hard drives.
d
F
Figure 4: Hard
d Disk with 3 p
platters
Looking
L at thhe Figure 4, we see that a hard disk iss composed of several phhysical
disks
d stackedd on top of eaach other. Thhe disk show wn in the Figuure 4 has 3 platters
p
and
a 6 recordiing surfaces (two on each h platter). A separate reaad head is provided
for
fo each surfa face. Althouggh the disks are made off continuous magnetic material, m
thhere is a limiit to the denssity of informmation whichh can be stored on the dissk. The
heads
h are controlled by a stepper motor m which moves them m in fixed-distance
inntervals acrooss each surfaace. i.e., theree is a fixed nuumber of traccks on each surface.
s
The
T tracks onn all the surfa faces are aliggned, and thee sum of all thet tracks at a fixed
distance
d fromm the edge off the disk is called a cyliinder. To maake the disk access
quicker,
q trackks are usuallly divided upp into sectorrs- or fixed size regionss which
liie along traccks. When w writing to a disk, data aare written inn units of a whole
number
n of secctors. (In this respect, theey are similaar to pages orr frames in phhysical
memory).
m On n some diskss, the sizes of sectors aree decided by y the manufaacturers
inn hardware. On other syystems (ofteen microcom mputers) it might
m be choosen in
software wheen the disk is prepared forr use (formatting). Becau use the headss of the
disk
d move toogether on all a surfaces, we can inccrease read-w write efficienncy by
allocating
a bllocks in parrallel across all surfaces. Thus, if a file is stoored in
consecutive
c b
blocks, on a disk with n surfaces
s and n heads, it could
c read n sectors
s
per-track
p withhout any heaad movementt. When a disk is suppliedd by a manufaacturer,
thhe physical properties
p of the disk (nnumber of traacks, numbeer of heads, sectors
s
per
p track, speeed of revoluution) are prrovided withh the disk. Ann operating system
must
m be able to adjust to ddifferent types of disk. C Clearly sectorrs per track iis not a
constant,
c norr is the numbber of trackss. The numbeers given aree just a convvention
used
u to work out a consisttent set of adddresses on a disk and mayy not have annything
too do with thee hard and faast physical limits
l of the disk. To adddress any porrtion of
a disk, we need a three component address connsisting of (ssurface, tracck and
sector).
46
The seek time is the time required for the disk arm to move the head to the I/O and File Management
cylinder with the desired sector. The rotational latency is the time required for
the disk to rotate the desired sector until it is under the read-write head.
3.5
3 DISK
K SCHEDULING
G
The
T disk is a resource whhich has to bee shared. It iis therefore has
h to be schheduled
for
fo use, accoording to som me kind of scheduling
s ssystem. The secondary sstorage
media
m structuure is one of the vital parts
p of the ffile system. Disks are thhe one,
providing
p lott of the secoondary storaage. As comppared to maagnetic tapess, disks
have
h very fasst access tim
me and disk bandwidth.
b T
The access time has twoo major
constituents:
c seek time annd the rotatioonal latency.
The
T seek tim me is the timme required forf the disk arm to movve the head to the
cylinder
c withh the desiredd sector. The rotational llatency is thee time requirred for
thhe disk to rotate the desirred sector unntil it is undeer the read-w
write head. Thhe disk
bandwidth
b is the total nummber of bytees transferredd per unit timme.
Both
B the acceess time andd the bandwiidth can be iimproved byy efficient diisk I/O
reequests scheeduling. Diskk drivers aree large singlee dimensionaal arrays of logical
blocks
b to be transferred. Because of large usagge of disks, proper scheeduling
algorithms
a arre required.
A schedulingg policy shoould attemptt to maximize throughpput (defined as the
number
n of requests servicced per unit time) and allso to minim
mize mean response
tiime (i.e., aveerage waiting time plus service
s time)). These schheduling algoorithms
are
a discussedd below:
3.5.1
3 FCF
FS Schedulling
First-Come,
F First-Servedd (FCFS) is the basis off this simpleest disk scheeduling
teechnique. Th
here is no reoordering of thhe queue. Supppose the reqquests for inpputting/
outputting
o to blocks on tthe cylinderss have arriveed, forming the followinng disk
queue:
q
50, 91, 1150, 42, 130,, 18, 140, 700, 60
Also
A assume that the diskk head is initiially at cylindder 50 then it
i moves to 91,
9 then
too 150 and so
s on. The ttotal head movement
m in this schemee is 610 cyllinders,
which
w makess the system slow becausse of wild sw wings. Propeer schedulingg while
moving
m towaards a particcular directiion could deecrease this. This will further
immprove perfformance. FC
CFS scheme is clearly deepicted in Fig gure 5.
48 Figure 5: FCFS
F Schedulling
3..5.2 SSTF
F Schedulin
ng I/O and File Management
Figure 6: SS
STF Schedulin
ng
3..5.3 SCAN
N Schedulling
Th he disk arm starts at onee end of the disk
d and servvice all the requests
r in itts way
towards the otther end, i.ee., until it reaaches the othher end of th
he disk wheere the
heead movemennt is reversed and continnue servicingg in this reverrse directionn. This
sccanning is doone back andd forth by thee head continnuously.
In
n the example problem tw wo things mu ust be knowwn before starrting the scaanning
prrocess. Firstlly, the initiaal head posittion i.e., 50 and then thee head moveement
diirection (let it
i towards 0, starting cyliinder). Consiider the diskk queue againn:
91, 150, 42, 130
0, 18, 140, 70,
7 60
Sttarting from 50 it will moove towards 0,0 servicing rrequests 42 and
a 18 in betwween.
Att cylinder 0 the directionn is reversedd and the arm
m will move towards the other
en
nd of the diskk servicing thhe requests at
a 60, 70, 91,130,140 andd then finally 150.
As the arm actts like an elevator in a buuilding, the SSCAN algoritthm is also kknown
ass elevator alggorithm someetimes. The liimitation of tthis scheme is that few reqquests
neeed to wait foor a long timee because of reversal of head
h directionn. This schedduling
alggorithm resu ults in a total head movem
ment of only 200 cylinderrs. Figure 7 showss
th
his scheme:
49
Memory Management, File
agement and Security
Mana
Figure 7: SCAN
S Schedulling
3.5.4
3 C-SC
CAN Scheduling
Similar
S to SC CAN algorithhm, C-SCAN N also movess head from one
o end to the other
servicing all the requestss in its way. The differeence here is that after thhe head
reeaches the ennd it immeddiately returnns to beginninng, skipping
g all the requests on
thhe return tripp. The serviccing of the requests
r is ddone only aloong one pathh. Thus
comparativel
c ly this schem
me gives uniiform wait tiime becausee cylinders aare like
circular
c lists that
t wrap aroound from thhe last cylindder to the firsst one.
3.5.5
3 LOO
OK and C--LOOK Sccheduling
These
T are jusst improvemeents of SCAAN and C-SC CAN but diffficult to impllement.
Here
H the headd moves onlyy till final request in eachh direction (first and lastt ones),
and
a immediaately reversees direction without going to end of o the disk. Before
moving
m towaards any direection the reequests are loooked, avoidding the fulll width
disk
d movemeent by the arm m.
The
T performaance and chooice of all thhese schedulling algorithm ms depend heavily
h
on
o the number and type of requests and on the nature of diisk usage. The T file
allocation
a meethods like contiguous,
c l
linked or inddexed, also affect
a the requests.
For
F example, a contiguously allocated d file will gennerate nearbyy requests andd hence
reeduce head movements whereas link ked or indexxed files may y generate reequests
from
fr blocks that are scatttered throug ghout the dissk and hencee increase thhe head
movements.
m W
While searchhing for filess the directorries will be frrequently acccessed,
hence
h locatioon of directoories and alsoo blocks of ddata in them are also impportant
criteria.
c All thhese peculiarrities force th
he disk scheeduling algorrithms to be written
w
as
a a separate module
m of thhe operating system, so thhat these cann easily be repplaced.
For
F heavily used u disks thhe SCAN / LOOKL algorrithms are well
w suited because
b
thhey take caree of the hardw ware and acccess requestss in a reasonaable order. T There is
no
n real dangeer of starvatioon, especiallly in the C-SCAN case. The T arrangem ment of
data
d on a diskk plays an im mportant role in deciding the t efficiency y of data-retrrieval.
3.6
3 RAIID
Disks
D have hiigh failure raates and hencce there is the risk of losss of data andd lots of
downtime
d foor restoring and disk reeplacement. To improvee disk usagee many
teechniques haave been im mplemented. One O such tecchnology is RAID (Reddundant
Array
A of Ineexpensive Disks).
D Its orrganization is based onn disk stripiing (or
innterleaving),, which uses a group of disks
d as one storage unit.. Disk stripinng is a
50 way
w of increasing the disk transfer rate r up to a factor of N,, by splittingg files
across N different disks. Instead of saving all the data from a given file on one I/O and File Management
disk, it is split across many. Since the N heads can now search independently, the
speed of transfer is, in principle, increased manifold. Logical disk data/blocks
can be written on two or more separate physical disks which can further transfer
their sub-blocks in parallel. The total transfer rate system is directly proportional
to the number of disks. The larger the number of physical disks striped together,
the larger the total transfer rate of the system. Hence, the overall performance
and disk accessing speed is also enhanced. The enhanced version of this scheme
is mirroring or shadowing. In this RAID organisation a duplicate copy of each
disk is kept. It is costly but a much faster and more reliable approach. The
disadvantage with disk striping is that, if one of the N disks becomes damaged,
then the data on all N disks is lost. Thus striping needs to be combined with a
reliable form of backup in order to be successful.
Another RAID scheme uses some disk space for holding parity blocks. Suppose,
three or more disks are used, then one of the disks will act as a parity block,
which contains corresponding bit positions in all blocks. In case some error occurs
or the disk develops a problems all its data bits can be reconstructed. This technique
is known as disk striping with parity or block interleaved parity, which increases
speed. But writing or updating any data on a disk requires corresponding
recalculations and changes in parity block. To overcome this the parity blocks
can be distributed over all disks.
Check Your Progress 1
1) Indicate the major characteristics which differentiate I/O devices.
........................................................................................................................
........................................................................................................................
........................................................................................................................
2) Explain the term device independence. What is the role of device drivers in
this context? 51
Memory Management, File ........................................................................................................................
Management and Security
........................................................................................................................
........................................................................................................................
4) What is the advantage of the double buffering scheme over single buffering?
........................................................................................................................
........................................................................................................................
........................................................................................................................
52 sectors useful in any logical block. But it is rare that physical record size will
exactly match the length of desired logical record. The designers are mainly I/O and File Management
interested in seeing how disk space is managed, how files are stored and how to
make everything work efficiently and reliably.
3.10.1 Directories
A file directory is a group of files organised together. An entry within a directory
refers to the file or another directory. Hence, a tree structure/hierarchy can be
formed. The directories are used to group files belonging to different applications/
users. Large-scale time sharing systems and distributed systems store thousands
of files and bulk of data. For this type of environment a file system must be
organised properly. A File system can be broken into partitions or volumes. They
provide separate areas within one disk, each treated as separate storage devices
in which files and directories reside. Thus directories enable files to be separated
on the basis of user and user applications, thus simplifying system management
issues like backups, recovery, security, integrity, name-collision problem (file
name clashes), housekeeping of files etc.
The device directory records information like name, location, size, and type for
all the files on partition. A root refers to the part of the disk from where the root
directory begins, which points to the user directories. The root directory is distinct 53
Memory Management, File from
fr sub-directories in that
t it is in a fixed posittion and of fixed size. So,
S the
Mana
agement and Security
directory
d is liike a symboll table that co
onverts file nnames into thheir correspoonding
directory
d entrries. The opeerations perfformed on a ddirectory or file
f system are:
a
1) Create, delete
d and moodify files.
2)
2 Search fo
or a file.
3 Mechanissms for sharring files should providee controlledd access like read,
3)
write, exeecute or variious combinaations.
4)
4 List the files
f in a direectory and also contents oof the directo
ory entry.
5)
5 Renaminng a file whenn its contentss or uses channge or file po
osition needss to be
changed.
6)
6 Backup anda recoveryy capabilitiees must be provided
p to prevent
p acciddental
loss or malicious
m desttruction of innformation.
7)
7 Traverse the file systeem.
The
T most com
mmon schem
mes for descriibing logicall directory sttructure are:
(ii) Single-leevel directorry
All the files
f are inside the sam me directory, which is siimple and easy e to
understannd; but the liimitation is that
t all files must
m have unnique namess. Also,
even witth a single uuser as the number
n of fi
files increasees, it is diffiicult to
remembeer and to tracck the namess of all the files.
fi This hieerarchy is deepicted
in Figuree 8.
Figure 8: Sin
ngle-level direcctory
54 Figure 9: Tw
wo-level directory
(iiii) Tree-stru
uctured direcctory I/O and File Management
F
Figure 11: Acyyclic-graph dirrectory
The limittations of thhis approachh are the diffficulties in trraversing ann entire
file systeem because of multiple absolute patth names. Another
A issuee is the
presence of dangling pointers to thet files that are already deleted, thouugh we
can overccome this byy preserving the file untill all references to it are deleted.
d
For this, every time a link or a coppy of directoory is establisshed, a new entry
e is
added to the file-refeerence list. But
B in realityy as the list is too lengthyy, only
a count of
o the numbeer of referencces is kept. T This count iss then increm mented
or decrem mented wheen the refereence to the file is addeed or it is ddeleted
respectivvely.
(vv) General graph Directory:
Acyclic-ggraph does nnot allow cyycles in it. However, wheen cycles exxist, the
referencee count mayy be non-zerro, even whhen the direcctory or file is not
referenceed anymore.. In such sittuation garbbage collectiion is useful. This
scheme requires the trraversal of thhe whole filee system and marking accessible
nly. The secoond pass then collects evverything thaat is unmarkeed on a
entries on
free-spacce list. This is depicted in
n Figure 12.
F
Figure 12: Gen
neral-graph diirectory
3.10.2
3 Dissk Space M
Managemeent
The
T direct-acccess of diskss and keeping g files in adjacent areas ofo the disk is highly
desirable.
d Buut the probleem is how to allocate sppace to filess for effectivve disk
space utilizattion and quicck access. Alsso, as files arre allocated and
a freed, thee space
on
o a disk become fragmennted. The maajor methodss of allocatinng disk spacee are:
56
i) Continuous I/O and File Management
Linked/C
Chained alloccation
Indexed Allocation.
A
Linked/Chai
L ined allocatiion: All filess are stored inn fixed size blocks
b and addjacent
blocks
b are linnked togetheer like a linkked list. Thee disk blockss may be scaattered
anywhere
a onn the disk. T The directorry contains a pointer too the first annd last
block
b of the file.
f Also eacch block conntains pointeers to the nex xt block, whhich are
not
n made avaailable to thee user. Theree is no externnal fragmenttation in this as any
free
fr block caan be utiliseed for storag ge. So, com mpaction andd relocation is not
reequired. Butt the disadvaantage here is i that it is pootentially ineefficient for direct-
accessible
a filles since blocks are scaattered overr the disk annd have to follow
pointers
p from
m one disk block to the neext. It can bee used effectiively for sequuential
access
a only but
b there alsoo it may gen nerate long seeks
s betweeen blocks. Another
A
isssue is the exxtra storage space requirred for pointters. Yet the reliability
r prroblem
iss also there due to loss/damage of any a pointer. The use of doubly linkeed lists
could
c be a so olution to thhis problem butb it wouldd add more overheads
o foor each
file.
fi A doubly linked listt also facilitaates searchinng as blockss are threadeed both
forward
fo and backward.
b T
The Figure 14 1 depicts linnked /chaineed allocationn where
each
e block contains the information
i about the nnext block (i.e., pointer to t next
block).
b
Figu
ure 14: Linked
d Allocation on
n the Disk
MS-DOS
M andd OS/2 use annother variatiion on linkedd list called FAAT (File Alloocation
Table).
T The beginning
b of each partitio
on contains a table havingg one entry foor each
disk
d block annd is indexedd by the blocck number. T The directory y entry contaains the
block
b number of the first block of filee. The table entry
e indexeed by block number
n
contains
c the block
b numbeer of the nexxt block in thhe file. The Table
T pointerr of the
laast block in the
t file has E EOF pointer value. This cchain continnues until EO OF (end
of
o file) table entry
e is encoountered. Wee still have too linearly travverse next poointers,
but
b at least we w don’t havee to go to thee disk for eacch of them. 0(Zero)
0 tablee value
inndicates an unused blocck. So, alloccation of freee blocks with FAT schheme is
straightforwaard, just searcch for the firrst block withh 0 table poiinter. MS-DO OS and
OS/2
O use thiss scheme. Thhis scheme iss depicted in Figure 15.
58
I/O and File Management
Figu
ure 15: File-A
Allocation Tablle (FAT)
Inndexed Alloccation: In thhis each file has h its own iindex block. Each entry of the
in
ndex points to o the disk bloocks containning actual fiile data i.e., the
t index keeeps an
arrray of blockk pointers foor each file. So, index bllock is an arrray of disk block
adddresses. Thee ith entry in the index bllock points too the ith block of the file. Also,
th
he main direcctory containns the addreess where thhe index block is on thee disk.
Innitially, all thhe pointers in
i index block are set too NIL. The advantage of o this
sccheme is thatt it supports both
b sequenttial and randoom access. The T searchingg may
takke place in inndex blocks themselves.
t T index bloocks may be kept
The k close toggether
in
n secondary storage to minimize
m seeek time. Alsoo space is wasted
w only on
o the
in
ndex which is not very laarge and therre’s no exterrnal fragmen ntation. But a few
lim
mitations of the previouus scheme stiill exists in this, like, we w still need to set
maximum
m file length and wew can have overflow schheme of the file f larger than the
prredicted valu ue. Insertionss can requiree complete rreconstructio on of index blocks
b
also. The indeexed allocatioon scheme iss diagrammaatically show wn in Figure 16.
3..10.3 Disk
k Address Translatioon
We
W have seen in Unit-1 meemory managgement that tthe virtual adddresses geneerated
byy a program is different from
f the phy
ysical. The trranslation off virtual addrresses
to physical addresses is peerformed by MMU. Diskk address trannslation considers
th k. Hard diskss are totally enclosed devices,
he aspects off data storagee on the disk
whhich are morre finely eng
gineered and therefore reqquire protecttion from duust. A
59
Memory Management, File hard disk spins at a constant speed. Briefly, hard disks consist of one or more
Management and Security
rotating platters. A read-write head is positioned above the rotating surface and
is able to read or write the data underneath the current head position. The hard
drives are able to present the “geometry” or “addressing scheme” of the drive.
Consider the disk internals first. Each track of the disk is divided into sections
called sectors. A sector is the smallest physical storage unit on the disk. The size
of a sector is always a power of two, and is almost always 512 bytes. A sector is
the part of a slice that lies within a track. The position of the head determines
which track is being read. A cylinder is almost the same as a track, except that it
means all tracks lining up under each other on all the surfaces. The head is
equivalent to side(s). It simply means one of the rotating platters or one of the
sides on one of the platters. If a hard disk has three rotating platters, it usually has
5 or 6 readable sides, each with its own read-write head.
The MS-DOS file systems allocate storage in clusters, where a cluster is one or
more contiguous sectors. MS-DOS bases the cluster size on the size of the
partition. As a file is written on the disk, the file system allocates the appropriate
number of clusters to store the file’s data. For the purposes of isolating special
areas of the disk, most operating systems allow the disk surface to be divided
into partitions. A partition (also called a cylinder group) is just that: a group of
cylinders, which lie next to each other. By defining partitions we divide up the
storage of data to special areas, for convenience. Each partition is assigned a
separate logical device and each device can only write to the cylinders, which are
defined as being its own. To access the disk the computer needs to convert physical
disk geometry (the number of cylinders on the disk, number of heads per cylinder,
and sectors per track) to a logical configuration that is compatible with the
operating system. This conversion is called translation. Since sector translation
works between the disk itself and the system BIOS or firmware, the operating
system is unaware of the actual characteristics of the disk, if the number of
cylinders, heads, and sectors per track the computer needs is within the range
supported by the disk. MS-DOS presents disk devices as logical volumes that
are associated with a drive code (A, B, C, and so on) and have a volume name
(optional), a root directory, and from zero to many additional directories and
files.
Check Your Progress 2
1) What is the meaning of the term ‘virtual device’? Give an Example.
........................................................................................................................
........................................................................................................................
........................................................................................................................
7) Assuming a cluster size of 512 bytes calculate the percentage wastage in file
space due to incomplete filling of last cluster, for the file sizes below:
(i) 1000 bytes (ii) 20,000 bytes
........................................................................................................................
........................................................................................................................
3.11 SUMMARY
This unit briefly describes the aspects of I/O and File Management. We started
by looking at I/O controllers, organisation and I/O buffering. We briefly described
various buffering approaches and how buffering is effective in smoothing out
the speed mismatch between I/O rates and processor speed. We also looked at
the four levels of I/O software: the interrupt handlers, device drivers, the device
independent I/O software, and the I/O libraries and user-level software.
A well-designed file system should provide a user-friendly interface. The file
system generally includes access methods, file management issues like file
integrity, storage, sharing, security and protection etc. We have discussed the
services provided by the operating system to the user to enable fast access and
processing of files. 63
Memory Management, File The important concepts related to the file system are also introduced in this unit
Management and Security
like file concepts, attributes, directories, tree structure, root directory, pathnames,
file services etc. Also a number of techniques applied to improve disk system
performance have been discussed and in summary these are: disk caching, disk
scheduling algorithms (FIFO, SSTF, SCAN, CSCAN, LOOK etc.), types of disk
space management (contiguous and non-contiguous-linked and indexed), disk
address translation, RAID based on interleaving concept etc. Auxiliary storage
management is also considered as it is mainly concerned with allocation of space
for files:
3.12 SOLUTIONS/ANSWERS
Check Your Progress 1
1) The major characteristics are:
Data Rate Disk-2Mbytes/sec
Keyboard-10-15 bytes/sec
Units of transfer Operation Disk-read, write, seek
Printer-write, move, select font
Error conditions Disk-read errors
Printer-paper out etc.
2) Device independence refers to making the operating system software and
user application independent of the devices attached. This enables the devices
to be changed at different executions. Output to the printer can be sent to a
disk file. Device drivers act as software interface between these I/O devices
and user-level software.
3) In some operating systems like UNIX, the driver code has to be compiled
and linked with the kernel object code while in some others, like MS-DOS,
device drivers are installed and loaded dynamically. The advantage of the
former way is its simplicity and run-time efficiency but its limitation is that
addition of a new device requires regeneration of kernel, which is eliminated
in the latter technique.
4) In double - buffering the transfers occur at maximum rate hence it sustains
device activity at maximum speed, while single buffering is slowed down by
buffer to transfer times.
5) The key objectives are to maximize the utilization of the processor, to operate
the devices at their maximum speed and to achieve device independence.
Check Your Progress 2
1) A virtual device is a simulation of an actual device by the operating system.
It responds to the system calls and helps in achieving device independence.
Example: Print Spooler.
2) Directories enable files to be separated on the basis of users and their
applications. Also, they simplify the security and system management
problems.
64
3) Major advantages are: I/O and File Management
= 2.3%
8) An alias is an alternative name for a file, possibly in a different directory. In
UNIX, a single inode is associated with each physical file. Alias names are
stored as separate items in directories but point to the same inode. It allows
one physical file to be referenced by two or more different names or same
name in different directory.
66
Security and Protection
UNIT 4 SECURITY AND PROTECTION
Structure
4.0 Introduction
4.1 Objectives
4.2 Security Threats
4.3 Security Policies and Mechanisms
4.4 Authentication
4.4.1 Passwords
4.4.2 Alternative Forms of Authentication
4.5 Protection in Computer Systems
4.6 Security Models
4.6.1 Access Matrix Model
4.6.2 Mandatory Access Control
4.6.3 Discretionary Access Control
4.6.4 Rule-Based Access Control
4.6.5 Role-Based Access Control
4.6.6 Take-Grant Model
4.6.7 Multilevel Models
4.7 Summary
4.8 Solutions/Answers
4.9 Further Readings
4.0 INTRODUCTION
Modern organisations depend heavily on their information systems and large
investments are made on them annually. These systems are now computerised,
and networking has been the common trend during the last decade. The availability
of information and computer resources within an organisation as well as between
cooperating organisations is often critical for the production of goods and services.
In addition, data stored in or derived from the system must be correct, i.e., data
integrity must be ensured. In some situations, it is also of great importance to
keep information confidential.
Computer security is traditionally defined by the three attributes of confidentiality,
integrity, and availability. Confidentiality is the prevention of unauthorised
disclosure of information. Integrity is the prevention of unauthorised modification
of information, and availability is the prevention of unauthorised withholding of
information or resources. 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 67
Memory Management, File unprotected resource cannot defend against use (or misuse) by an unauthorised
Management and Security
or incompetent user.
Even if a perfectly secure operating system was created, human error (or purposeful
human malice) can make it insecure. More importantly, there is no such thing as
a completely secure system. No matter how secure the experts might think a
particular system is, there exists someone who is clever enough to bypass the
security.
This unit discusses about the various types of security threats and the commonly
deployed detective and preventive methods.
4.1 OBJECTIVES
After going through this unit, you should be able to:
identify the security threats and goals;
mention the role of security policies and mechanisms;
discuss the significance of authentication and also describe various types of
authentication procedures, and
describe the various models of protection.
Security evaluations have been performed for quite some time by mainly two
different methods. The first is to classify systems into a predefined set of categories,
each with different security requirements. The other method is referred to as
penetration testing, which is a form of stress testing exposing weaknesses in a
system. Here, the idea is to let a group of people, normally very skilled in the
computer security area, attack a target system.
4.4 AUTHENTICATION
It is the process of verifying a user’s identity (who you are) through the use of a
shared secret (such as a password), a physical token or an artifact (such as a key
or a smart card), or a biometric measure (such as a fingerprint).
The types and rigor of authentication methods and technologies vary according
to the security requirements or policies associated with specific situations and
implementations.
The most common and least stringent form of authentication technology demands
that users provide only a valid account name and a password to obtain access to
a system or network. The password-based authentication is one-way and normally
stores the user-id and password combination in a file that may be stored on the
server in an encrypted or plaintext file. Most people using the public e-mail systems
use this form of authentication.
Protection of Passwords
Some systems store the passwords of all users in a protected file. However, this
scheme is vulnerable to accidental disclosure and to abuse by system
administrators.
UNIX stores only an encrypted form of every password; a string is the password
of user X if its encrypted form matches the encrypted password stored for X.
The encrypted password is accessible to everyone, but one cannot find the clear
text password without either guessing it or breaking the encryption algorithm.
Data Encryption Standard (DES)
Encryption is based on one-way functions: functions that are cheap to compute
but whose inverse is very expensive to compute. A still widely used, though
older encryption algorithm is the Data Encryption Standard (DES), which uses a
56bit key.
UNIX does not encrypt passwords with a secret key, instead, it uses the password
as the key to encrypt a standard string. The latter method is not as vulnerable to
attacks based on special properties of the “secret” key, which must nevertheless
be known to many people.
Limitations of Passwords
Users tend to choose passwords that are easy to guess; persistent guessing attacks
can find 80-90% of all passwords. Good guesses include the login name, first
names, treat names, words in the on-line dictionary, and any of these reversed or
doubled.
The way to defeat these attacks is to choose a password that does not fall into any
of those categories. Preferably passwords should contain some uppercase letters,
numbers and/or special characters; their presence increases the search space by a
large factor.
To protect the computer systems, we often need to apply some security models.
Let us see in the next section about the various security models available.
The Security Policy outlines several high level points: how the data is accessed,
the amount of security required, and what the steps are when these requirements
are not met. The security model is more in depth and supports the security policy.
Security models are an important concept in the design of any security system.
They all have different security policies applying to the systems.
Objects are typically files, terminals, devices, and other entities implemented by
an operating system. A subject is a process and a domain (a set of constraints
within which the process may access certain objects). It is important to note that
every subject is also an object; thus it may be read or otherwise manipulated by
another subject. The access matrix is a rectangular array with one row per subject
and one column per object. The entry for a particular row and column reflects the
mode of access between the corresponding subject and object. The mode of access
allowed depends on the type of the object and on the functionality of the system;
typical modes are read, write, append, and execute.
73
Memory Management, File
Management and Security Objects File 1 File 2
File 3
Subject
User 1 r, w R r, w, x
User 2 r R r, w, x
User 3 r, w, x r, w r, w, x
Figure 1: An access matrix
All accesses to objects by subjects are subject to some conditions laid down by
an enforcement mechanism that refers to the data in the access matrix. This
mechanism, called a reference monitor, rejects any accesses (including improper
attempts to alter the access matrix data) that are not allowed by the current
protection state and rules. References to objects of a given type must be validated
by the monitor for that type.
While implementing the access matrix, it has been observed that the access matrix
tends to be very sparse if it is implemented as a two-dimensional array.
Consequently, implementations that maintain protection of data tend to store
them either row wise, keeping with each subject a list of the objects and access
modes allowed on it; or column wise, storing with each object a list of those
subjects that may access it and the access modes allowed on each. The former
approach is called the capability list approach and the latter is called the access
control list approach.
In general, access control governs each user’s ability to read, execute, change, or
delete information associated with a particular computer resource. In effect, access
control works at two levels: first, to grant or deny the ability to interact with a
resource, and second, to control what kinds of operations or activities may be
performed on that resource. Such controls are managed by an access control
system. Today, there are numerous methods of access controls implemented or
practiced in real-world settings. These include the methods described in the next
four sections.
Role definitions and associated access rights must be based upon a thorough
understanding of an organisation’s security policy. In fact, roles and the access
rights that go with them should be directly related to elements of the security
policy.
Take-grant models use graphs to model access control. They have been well
researched. Although explained in the terms of graph theory, these models are
fundamentally access matrix models. The graph structure can be represented as
an adjacency matrix, and labels on the arcs can be coded as different values in
the matrix.
For example, if there is an arc labeled (r, g) from node B to node C, and if the arc
from A to B includes a “t” in its label, then an arc from A to C labeled (r, g) could
be added to the graph (see Figure 2). Conversely, if the arc from Ato B is marked
with a “g”, B can be granted any access right A possesses. Thus, if A has (w)
access to a node D and (g) access to B, an arc from B to D marked (w) can be
added to the graph (see Figure 3).
75
Memory Management, File
Mana
agement and Security
Figure 2: Example
E of Taake
Figure 3: Example
E of Grrant
Because
B the graph needss only the innclusion of aarcs correspo onding to noon-null
entries
e in thee access maatrix, it provvides a compmpact way too present thee same
innformation given
g in a reelatively spaarse access matrix.
m Capaability systemms are
thhus prime caandidates forr this modelinng techniquee; each arc would then reppresent
a particular capability.
c Toogether with the protection graph, thhe model inclludes a
set of rules foor adding andd deleting bo oth nodes annd arcs to thee graph.
Two
T of these, correspondding to the exxercise of “ttake” and “grrant” access rights,
have
h already been describbed. A “creaate” rule alloows a new node to be addded to
thhe graph. If subject A creates a new node Y, bothh the node Y and an arc A AY are
added
a to the graph. The llabel on AYY includes anyy subset of the
t possible access
riights. A “remmove” rule allows
a an acccess right to be removedd from an arcc; if all
riights are rem
moved from aan arc, the arrc is removed as well.
4.6.7
4 Mulltilevel Moodels
This
T type of models
m correesponds to thee multilevel policies
p wheere data is claassified
innto sensitivitty levels and users have acccess accordding to their clearances.
c B
Because
of
o the way thhey control security theyy have also been called data flow models, m
thhey control the
t allowed fflow of data between levvels.
The Bell--La Padula m
model, intendeed to control leakage
l of infformation bettween
levels.
76
The Biba model, which controls the integrity. Security and Protection
The Lattice model, which generalises the partially ordered levels of the
previous models using the concept of mathematical lattices.
Bell and La Padula Model
Bell and La Padula use finite-state machines to formalise their model. They define
the various components of the finite state machine, define what it means (formally)
for a given system state to be secure, and then consider the transitions that can be
allowed so that a secure state can never lead to an insecure state.
In addition to the subjects and objects of the access matrix model, it includes the
security levels of the military security system: each subject has a authority and
each object has a classification. Each subject also has a current security level,
which may not exceed the subject’s authority. The access matrix is defined as
above, and four modes of access are named and specified as follows:
Read-only: subject can read the object but not modify it;
Append: subject can write the object but cannot read it;
Execute: subject can execute the object but cannot read or write it directly;
and
Read-write: subject can both read and write the object.
A control attribute, which is like an ownership flag, is also defined. It allows a
subject to pass to other subjects some or all of the access modes it possesses for
the controlled object. The control attribute itself cannot be passed to other subjects;
it is granted to the subject that created the object.
For a system state to be secure, it should hold the following two properties:
(1) The simple security property: No subject has read access to any object that
has a classification greater than the clearance of the subject; and
(2) The *-property (pronounced “star-property”): No subject has append-access
to an object whose security level is not at least the current security level of
the subject; no subject has read-write access to an object whose security
level is not equal to the current security level of the subject; and no subject
has read access to an object whose security level is not at most the current
security level of the subject.
An example restatement of the model is discussed below:
In this case, we use security levels as (unclassified < confidential < secret <
top-secret).
The security levels are used to determine appropriate access rights.
The essence of the model can be defined as follows:
4.7 SUMMARY
Security is an important aspect of an OS. The distinction between security and
protection is:
Security: Broad sense to refer all concerns about controlled access to facilities.
Protection: Mechanism to support security.
In this unit, we have discussed the concept of security and various threats to it.
Also we have discussed various protection and security mechanisms to enforce
security to the system.
2) The logical place to store authorisation information about a file is with the
file itself or with its inode.
80
Each element of an Access Control List (ACL) contains a set of user names Security and Protection
and a set of operation names. To check whether a given user is allowed to
perform a given operation, the kernel searches the list until it finds an entry
that applies to the user, and allows the access if the desired operation is
named in that entry. The ACL usually ends with a default entry. Systems that
use ACLs stop searching when they find an ACL entry that applies to the
subject. If this entry denies access to the subject, it does not matter if later
entries would also match and grant access; the subject will be denied access.
This behaviour is useful for setting up exceptions, such as everyone can
access this file except people in this group.
81
MCS--203
O
Operati
ing Systeems
In
ndira Gandhi
Naational Open University
U
Scchool of Compuuter and
In
nformation Scieences
Block
B
3
ADVANC
A ED TOP
PICS IN OPERAT
O TING SY
YSTEMS
UNIT
U 1
Multiproce
M ssor Systeems 5
UNIT
U 2
Distributed
D d Operatinng System
ms 19
UNIT
U 3
Mobile
M Operating Syystems 48
PROGRAMME/COURSE DESIGN COMMITTEE
Prof. Sanjeev K. Aggarwal, IIT, Kanpur Shri Sanjeev Thakur
Shri Navneet Aggarwal Amity School of Computer Sciences, Noida
Trinity BPM, New Delhi Shri Amrit Nath Thulal
Prof. M. Balakrishnan, IIT, Delhi Amity School of Engineering and Technology
Prof. Pandurangan, C., IIT, Madras New Delhi
Ms. Bhoomi Gupta Dr. Om Vikas(Retd), Ex-Sr. Director,
Sirifort College of Computer and Technology Ministry of ICT, Delhi
Management, New Delhi Shri Vishwakarma
Shri Manoj Kumar Gupta Amity School of Engineering and Technology
Keane India Ltd., New Delhi New Delhi
Shri Sachin Gupta Prof (Retd) S. K. Gupta, IIT Delhi
Delhi Institute of Advanced Studies, Prof. T.V. Vijaya Kumar, Dean, SC&SS,
New Delhi JNU, New Delhi
Prof. Harish Karnick, IIT, Kanpur Prof. Ela Kumar, Dean, CSE, IGDTUW, Delhi
Shri Anil Kumar
Prof. Gayatri Dhingra, GVMITM, Sonipat
Amity School of Engineering and Technology
New Delhi Sh. Milind Mahajani Vice President,
Dr. Kapil Kumar, IIMT, Meerut Impressico Business Solutions, Noida, UP
Dr. Sachin Kumar, Prof. V. V. Subrahmanyam, Director
SOCIS, New Delhi
CCS University, Meerut
Ms. Manjulata Prof. P. V. Suresh,
Amity School of Engineering and Technology SOCIS, IGNOU, New Delhi
New Delhi Dr. Shashi Bhushan
Shri Ajay Rana SOCIS, IGNOU, New Delhi
Amity School of Computer Sciences, Noida Shri Akshay Kumar, Associate Prof.
Dr. Divya Sharma SOCIS, IGNOU, New Delhi
Bharati College, Delhi Shri M. P. Mishra, Associate Prof.
Shri Neeraj Sharma SOCIS, IGNOU, New Delhi
Havard Institute of Management Technology Dr. Sudhansh Sharma, Asst. Prof
Noida SOCIS, IGNOU, New Delhi
PRINT PRODUCTION
Mr. Tilak Raj Mr. Yashpal
Asst. Registrar (Pub.) Section Officer (Pub.)
MPDD, IGNOU, New Delhi MPDD, IGNOU, New Delhi
March, 2021
© Indira Gandhi National Open University, 2021
All rights reserved. No part of this work may be reproduced in any form, by mimeograph or any other
means, without permission in writing from the Indira Gandhi National Open University.
Further information on the Indira Gandhi National Open University courses may be obtained from the
University’s office at Maidan Garhi, New Delhi-110068.
Printed and published on behalf of the Indira Gandhi National Open University, New Delhi by the
MPDD, IGNOU, New Delhi
Laser Typesetting : Akashdeep Printers, 20-Ansari Road, Daryaganj, New Delhi-110002
Printed at :
BLOCK INTRODUCTION
This block introduces you with the advanced topics in Operating Systems like
the Mulitprocessor systems, Distributed Operating Systems and Mobile Operating
Systems.
The block is organised into 3 units.
Unit 2 covers the OS technology to support the distributed computing. The unit
starts with the discussion on the need of the distributed systems, design goals
and design issues pertaining to the distributed systems. Also it focuses on various
models of distributed systems, Remote procedure calls and Distributed shared
memory.
4
Multiprocessor Systems
UNIT 1 MULTIPROCESSOR SYSTEMS
Structure
1.1 Introduction
1.2 Objectives
1.3 Multiprocessing and Processor Coupling
1.4 Multiprocessor Interconnections
1.4.1 Bus-oriented System
1.4.2 Crossbar-connected System
1.4.3 Hypercubes System
1.4.4 Multistage Switch-based System
1.5 Types of Multiprocessor Operating Systems
1.5.1 Separate Supervisors
1.5.2 Master-Slave
1.5.3 Symmetric
1.6 Multiprocessor Operating System - Functions and Requirements
1.7 Multiprocessor Synchronization
1.7.1 Test-and-set
1.7.2 Compare-and-Swap
1.7.3 Fetch-and-Add
1.8 Summary
1.9 Solutions / Answers
1.10 Further Readings
1.0 INTRODUCTION
A multiprocessor system is a collection of a number of standard processors put
together in an innovative way to improve the performance / speed of computer
hardware. The main feature of this architecture is to provide high speed at low
cost in comparison to uniprocessor. In a distributed system, the high cost of
multiprocessor can be offset by employing them on a computationally intensive
task by making it compute server. The multiprocessor system is generally
characterised by - increased system throughput and application speedup - parallel
processing.
Throughput can be improved, in a time-sharing environment, by executing a
number of unrelated user processor on different processors in parallel. As a result
a large number of different tasks can be completed in a unit of time without
explicit user direction. On the other hand application speedup is possible by
creating a multiple processor scheduled to work on different processors.
The scheduling can be done in two ways:
1) Automatic means, by parallelising compiler.
2) Explicit-tasking approach, where each programme submitted for execution
is treated by the operating system as an independent process. 5
Advanced Topics in Multiprocessor operating systems aim to support high performance through
Operating Systems
multiple CPUs. An important goal is to make the number of CPUs transparent
to the application. Achieving such transparency is relatively easy because the
communication between different (parts of) applications uses the same
primitives as those in multitasking uni-processor operating systems. The idea
is that all communication is done by manipulating data at shared memory
locations, and that we only have to protect that data against simultaneous access.
Protection is done through synchronization primitives like semaphores and
monitors.
In this unit we will study multiprocessor coupling, interconnections, types of
multiprocessor operating systems and synchronization.
1.1 OBJECTIVES
After going through this unit, you should be able to:
define a multiprocessor system;
describe the architecture of multiprocessor and distinguish among various
types of architecture;
become familiar with different types of multiprocessor operating systems;
discuss the functions of multiprocessors operating systems;
describe the requirement of multiprocessor in Operating System, and
discuss the synchronization process in a multiprocessor system.
Figure 1. B
Bus-oriented multiprocessor
m r interconnecttion
The
T above arrchitecture giives rise to a problem of contention at a two points, one is
shared bus itsself and the otther is sharedd memory. Emmploying priivate/cache memory
m
inn either of two
t ways, explained
e beelow, the prooblem of coontention coould be
reeduced;
with sharred memory;; and
with cachhe associatedd with each individual
i prrocessor
1) With shaared memorry
2)
2 Cache asssociated wiith each ind
dividual processor.
Figu
ure 3: Individu
ual processors with cache
T second approach
The a wheere the cache is associatedd with each inndividual processor
8 iss the most popular
p apprroach becausse it reducess contention more effecttively.
Caache attacheed with proceessor an captture many of the local memory
m referrences Multiprocesssor Systems
fo
or example, with a cache of 90% hit ratio, a prrocessor on average neeeds to
acccess the sharred memory for 1 (one) outo of 10 (tenn) memory references beecause
9 (nine) refereences are alreeady captureed by privatee memory off processor. IIn this
caase where memory
m accesss is uniformmly distributted a 90% cache hit ratiio can
su
upport the shared bus to speed-up
s 10 times
t more thhan the proceess without ccache.
Th he negative aspect
a of suchh an arrangem
ment arises wwhen in the prresence of muultiple
caache the shaared writablee data are cached.
c In thhis case Cacche Coherennce is
maintained
m to consistencyy between multiple
m physical copies of o a single loogical
daatum with eacch other in th
he presence ofo update acttivity. Yes, thhe cache coheerence
caan be mainttained by atttaching add ditional harddware or byy including some
sppecialised prrotocols designed for the t same buut unfortunaately this sppecial
arrrangement will
w increase the t bus traffiic and thus reeduce the bennefit that proccessor
caaches are dessigned to proovide.
nce refers to the integrity
Caache coheren y of data storred in local caches
c of a shared
s
resource. Cach
he coherencee is a special case of mem mory coherennce.
When
W clients in
i a system, particularly
p C
CPUs in a muultiprocessingg system, maaintain
caaches of a co ommon mem mory resourcee, problems arise. Referrring to the F Figure
4, if the top cllient has a copy
c of a meemory block from a prevvious read annd the
boottom client changes
c that memory
m blocck, the top client could be left with an innvalid
caache of mem mory without it knowing any a better. C Cache cohereence is intendded to
manage
m such conflicts
c and maintain con nsistency bettween cache and memoryy.
Leet us discuss some techniiques which can be emplooyed to decrrease the imppact of
buus and memoory saturationn in bus-orieented system
m.
1)) Wider Bu us Techniqu ue: As suggeested by its name a bus is made widder so
that more bytes can be b transferredd in a singlee bus cycle. In other woords, a
wider parallel bus inccreases the bandwidth
b byy transferrinng more bytees in a
single buss cycle. Thee need of bu us transactioon arises wh hen lost or m
missed
blocks aree to fetch intoo his processsor cache. Inn this transacction many syystem
supports, block-level reads
r and wrrites of mainn memory. Inn the similar way,
w a
missing block
b can bee transferred from the m main memoryy to his proccessor
cache onlyy by a singlee main-mem mory (block) rread action. The advantaage of
block leveel access to memory
m overr word-oriennted busses is the amortizzation
of overhead addressin ng, acquisitioon and arbitrration over a large numbber of
items in a block. Moreover, it also enjoyed
e speccialised burstt bus cycles, w
which
makes theeir transport more
m efficien nt.
2)) Split Req
quest/Reply Protocols:
P T memory request and reply are spllit into
The
two indiviidual works and
a are treateed as separatte bus transacctions. As sooon as 9
Adva
anced Topics in a processsor requests a block, thee bus releaseed to other user,
u meanwwhile it
Operating Systems
takes for memory to ffetch and asssemble the reelated groupp of items.
The
T bus-oriennted system is the simplest architeccture of multtiprocessor system.s
In
n this way itt is believedd that in a tigghtly coupleed system thiis organisation can
support on th
he order of 10 1 processors. However, the two conntention poinnts (the
bus
b and the shhared memoory) limit thee scalability oof the system m.
1.3.2
1 Crosssbar-Con
nnected Sy
ystem
Crossbar-con
C nnected Systeem (illustrateed in Figure 5)
5 is a grid strructure of proocessor
and
a memory modules. The every crooss point of grid structuure is attacheed with
switch. By loooking at thee Figure it seeems to be a contention free
f architeccture of
multiprocessi
m ing system, it shows sim multaneous access betw ween processsor and
memory
m mod dules as N number
n of processors arre provided with N num mber of
memory
m mod dules. Thus each processsor accesses a differentt memory module. m
Crossbar
C needs N switchhes for fully connected
2
c neetwork betwween processoors and
memory.
m Processors mayy or may nott have their private mem mories. In thhe later
case
c the systeem supports uniform-mem mory-accesss.
Fiigure 5: Crossb
bar-connected
d system
Where
W P= proocessor, M=Memory Moodule and =S
Switch
But
B Unfortunnately this syystem also faaces the problem of conteention when,,
1) More thaan two proceessors (P1 and a P2) attem mpt to accesss the one memory
m
module (M1)
( at the ssame time. Inn this condittion, contentiion can be avvoided
by makinng any one pprocessor (P1 1) deferred uuntil the otheer one (P2) finishes
fi
this workk or left the ssame memorry module (M M1) free for processor
p P11.
2)
2 More thaan two proceessor attemptts to access tthe same mem
mory module. This
problem cannot be soolved by above-mentioneed solution.
Thus
T in crosssbar connecction system m the probleem of conten ntion occurss on at
memory
m neithher at processsor nor at innterconnectioon networks level. The soolution
10 of
o this problemm includes qquadratic grow wth of its sw
witches as welll as its compplexity
levvel. Not onlyy this, it willl make the whole
w system
m expensive and also lim
mit the Multiprocesssor Systems
sccalability of the
t system.
Figure 6: Hy
ypercubes Systtem 11
Advanced Topics in
Operating Systems
1.3.4 Multistage Switch Based system
Multistage Switch Based System permits simultaneous connection between
several input-output pairs. It consists of several stages of switches which provide
multistage interconnection network. A N input-output connections contains K=
log N stages of N/ switches at each stage. In simple words, N*N processor-memory
2 2
interconnection network requires (N/ ) x = log N switches.
2 2
1.4.2 Master-Slave
In master-slave, out of many processors one processor behaves as a master whereas
others behave as slaves. The master processor is dedicated to executing the
operating system. It works as scheduler and controller over slave processors. It
schedules the work and also controls the activity of the slaves. Therefore, usually
data structures are stored in its private memory. Slave processors are often
identified and work only as a schedulable pool of resources, in other words, the
slave processors execute application programmes.
This arrangement allows the parallel execution of a single task by allocating
several subtasks to multiple processors concurrently. Since the operating system
is executed by only master processors this system is relatively simple to develop
and efficient to use. Limited scalability is the main limitation of this system,
because the master processor become a bottleneck and will consequently fail to
fully utilise slave processors.
1.4.3 Symmetric
In symmetric organisation all processors configuration are identical. All processors
are autonomous and are treated equally. To make all the processors functionally
identical, all the resources are pooled and are available to them. This operating
system is also symmetric as any processor may execute it. In other words there is
one copy of kernel that can be executed by all processors concurrently. To that
end, the whole process is needed to be controlled for proper interlocks for
accessing scarce data structure and pooled resources.
The simplest way to achieve this is to treat the entire operating system as a critical
section and allow only one processor to execute the operating system at one
time. This method is called ‘floating master’ method because in spite of the
presence of many processors only one operating system exists. The processor
that executes the operating system has a special role and acts as a master. As the
operating system is not bound to any specific processor, therefore, it floats from
one processor to another.
1.6.1 Test-and-Set
The test-and-set instruction automatically reads and modifies the contents of a
memory location in one memory cycle. It is as follows:
function test-and-set (var m: Boolean); Boolean;
begin
test-and set:=m;
m:=rue
end;
The test-and-set instruction returns the current value of variable m (memory
location) and sets it to true. This instruction can be used to implement P and V
operations (Primitives) on a binary semaphore, S, in the following way (S is
implemented as a memory location):
P(S): while Test-and-Set (S) do nothing;
V(S): S:=false;
Initially, S is set to false. When a P(S) operation is executed for the first time,
test-and-set(S) returns a false value (and sets S to true) and the “while” loop of
the P(S) operation terminates. All subsequent executions of P(S) keep looping
because S is true until a V(S) operation is executed.
1.6.2 Compare-and-Swap
The compare and swap instruction is used in the optimistic synchronization of
concurrent updates to a memory location. This instruction is defined as follows
(r1and r2 are to registers of a processor and m is a memory location):
function test-and-set (var m: Boolean); Boolean;
var temp: integer;
begin
temp:=m;
15
Advanced Topics in if temp = r1 then {m:= r2;z:=1}
Operating Systems
else [r1:= temp; z:=0}
end;
If the contents of r1 and m are identical, this instruction assigns the contents of
r2 to m and sets z to 1. Otherwise, it assigns the contents of m to r1 and set z to 0.
Variable z is a flag that indicates the success of the execution. This instruction
can be used to synchronize concurrent access to a shared variable.
1.6.3 Fetch-and-Add
The fetch and add instruction is a multiple operation memory access instruction
that automatically adds a constant to a memory location and returns the previous
contents of the memory location. This instruction is defined as follows:
Function Fetch-and-add (m: integer; c: integer);
Var temp: integer;
Begin
Temp:= m;
M:= m + c;
Return (temp)
end;
This instruction is executed by the hardware placed in the interconnection network
not by the hardware present in the memory modules. When several processors
concurrently execute a fetch-and-add instruction on the same memory location,
these instructions are combined in the network and are executed by the network
in the following way:
A single increment, which is the sum of the increments of all these instructions,
is added to the memory location.
A single value is returned by the network to each of the processors, which is
an arbitrary serialisation of the execution of the individual instructions.
If a number of processors simultaneously perform fetch-and-add instructions
on the same memory location, the net result is as if these instructions were
executed serially in some unpredictable order.
The fetch-and-add instruction is powerful and it allows the implementation of P
and V operations on a general semaphore, S, in the following manner:
P(S): while (Fetch-add-Add(S, -1)< 0) do
begin
Fetch-and-Add (S, 1);
while (S<0) do nothing;
end;
The outer “while-do” statement ensures that only one processor succeeds in
decrementing S to 0 when multiple processors try to decrement variable S. All
the unsuccessful processors add 1 back to S and try again to decrement it. The
“while-do” statement forces an unsuccessful processor to wait (before retrying)
16
until S is greater then 0. Multiprocessor Systems
Check Your Progress 1
1) What is the difference between a loosely coupled system and a tightly coupled
system? Give examples.
........................................................................................................................
........................................................................................................................
........................................................................................................................
........................................................................................................................
1.7 SUMMARY
Multiprocessors systems architecture provides higher computing power and speed.
It consists of multiple processors that putting power and speed to the system.
This system can execute multiple tasks on different processors concurrently.
Similarly, it can also execute a single task in parallel on different processors. The
design of interconnection networks includes the bus, the cross-bar switch and
the multistage interconnection networks. To support parallel execution this system
must effectively schedule tasks to various processors. And also it must support
primitives for process synchronization and virtual memory management. The
three basic configurations of multiprocessor operating systems are: Separate
supervisors, Master/slave and Symmetric. A multiprocessor operating system
manages all the available resources and schedule functionality to form an
abstraction. It includes Process scheduling, Memory management and Device
management. Different mechanism and techniques are used for synchronization
in multiprocessors to serialize the access of pooled resources. In this section we
have discussed Test-and-Set, Compare-and-Swap and Fetch-and-Add techniques
of synchronization.
1.8 SOLUTIONS/ANSWERS
1) One feature that is commonly characterizing tightly coupled systems is that
they share the clock. Therefore, multiprocessors are typically tightly coupled
but distributed workstations on a network are not.
Another difference is that: in a tightly-coupled system, the delay experienced
when a message is sent from one computer to another is short, and data rate
is high; that is, the number of bits per second that can be transferred is large. 17
Advanced Topics in In a loosely-coupled system, the opposite is true: the intermachine message
Operating Systems
delay is large and the data rate is low.
For example, two CPU chips on the same printed circuit board and connected
by wires etched onto the board are likely to be tightly coupled, whereas two
computers connected by a 2400 bit/sec modem over the telephone system
are certain to be loosely coupled.
2) The difference between symmetric and asymmetric multiprocessing: all
processors of symmetric multiprocessing are peers; the relationship between
processors of asymmetric multiprocessing is a master-slave relationship. More
specifically, each CPU in symmetric multiprocessing runs the same copy of
the OS, while in asymmetric multiprocessing, they split responsibilities
typically, therefore, each may have specialised (different) software and roles.
18
Distributed Operating
UNIT 2 DISTRIBUTED OPERATING Systems
SYSTEMS
Structure
2.1 Introduction
2.2 Objectives
2.3 History of Distributed Computing
2.3.1 Workstations – Networks
2.3.2 Wide-Scale Distributed Computing and the Internet
2.4 Distributed Systems
2.5 Key Features and Advantages of a Distributed System
2.5.1 Advantages of Distributed Systems Over Centralised Systems
2.5.2 Advantages of Distributed Systems over Isolated PC’s
2.5.3 Disadvantages of Distributed Systems
2.6 Design Goals of Distributed Systems
2.6.1 Concurrency
2.6.2 Scalability
2.6.3 Openness
2.6.4 Fault Tolerance
2.6.5 Privacy and Authentication
2.6.6 Transparency
2.7 Design Issues Involved in Distributed Systems
2.7.1 Naming
2.7.2 Communication
2.7.3 Software Structure
2.7.4 Workload Allocation
2.7.5 Consistency Maintenance
2.7.6 Lamport’s Scheme of Ordering of Events
2.8 Distributed System Structure
2.8.1 Application Model 1: Client Server
2.8.2 Application Model 2: Distributed Objects
2.8.3 Application Model 3: Distributed Shared Memory
2.9 Mutual Exclusion in Distributed Systems
2.9.1 Mutual Exclusion Servers
2.9.2 Token Based Mutual Exclusion
2.9.3 Lamport’s Bakery Algorithm
2.9.4 Ricart and Agrawala’s Mutual Exclusion Algorithm
2.10 Remote Procedure Calls
2.10.1 How RPC Works?
2.10.2 Remote Procedure Calling Mechanism
2.10.3 Implementation of RPC
2.10.4 Considerations for Usage
2.10.5 Limitations
2.11 Other Middleware Technologies
2.12 Summary
2.13 Solutions/Answers
2.14 Further Readings 19
Advanced Topics in
Operating Systems 2.0 INTRODUCTION
In the earlier unit we have discussed the Multiprocessor systems. In the process
coupling we have come across the tightly coupled systems and loosely coupled
systems. In this unit we concentrate on the loosely coupled systems called as the
distributed systems. Distributed computing is the process of aggregating the
power of several computing entities to collaboratively run a computational task
in a transparent and coherent way, so that it appears as a single, centralised system.
The easiest way of explaining what distributed computing is all about, is by
naming a few of its properties:
Distributed computing consists of a network if more or less independent or
autonomous nodes.
The nodes do not share primary storage (i.e., RAM) or secondary storage
(i.e., disk) - in the sense that the nodes cannot directly access another node’s
disk or RAM. Think about it in contrast to a multiprocessors machine where
the different “nodes” (CPUs)) share the same RAM and secondary storage
by using a common bus.
A well designed distributed system does not crash if a node goes down.
If you are to perform a computing task which is parallel in nature, scaling
your system is a lot cheaper by adding extra nodes, compared to getting a
faster single machine. Of course, if your processing task is highly non-parallel
(every result depends on the previous), using a distributed computing system
may not be very beneficial.
Before going into the actual details of the distributed systems let us study how
distributed computing evolved.
2.1 OBJECTIVES
After going through this unit, you should be able to:
define a distributed system, key features and design goals of it;
explain the design issues involved in the distributed systems;
describe the models of distributed system structure;
explain the mutual exclusion in distributed systems, and
define RPC, its usage and limitations.
2.2.1 Workstations-Networks
The vision of the PARC research (and the commercial systems that followed)
was to replace the timesharing mini-computer with single-user workstations. The
genesis of this idea is that it made computers (i.e., workstations and PCs) into a
commodity item that like a TV or a car could be produced efficiently and cheaply.
The main costs of a computer are the engineering costs of designing it and
designing the manufacturing process to build it. If you build more units, you can
amortised the engineering costs better and thus make the computers cheaper.
This is a very important idea and is the main reason that distribution is an excellent
way to build a cheap scalable system.
2.5.1 Concurrency
A server must handle many client requests at the same time. Distributed systems
are naturally concurrent; that is, there are multiple workstations running programs
independently and at the same time. Concurrency is important because any
distributed service that isn’t concurrent would become a bottleneck that would
serialise the actions of its clients and thus reduce the natural concurrency of the
system.
2.5.2 Scalability
The goal is to be able to use the same software for different size systems. A
distributed software system is scalable if it can handle increased demand on any
part of the system (i.e., more clients, bigger networks, faster networks, etc.) without
a change to the software. In other words, we would like the engineering impact
of increased demand to be proportional to that increase. Distributed systems,
however, can be built for a very wide range of scales and it is thus not a good idea
to try to build a system that can handle everything. A local-area network file
server should be built differently from a Web server that must handle millions of
requests a day from throughout the world. The key goal is to understand the
target system’s expected size and expected growth and to understand how the
distributed system will scale as the system grows.
2.5.3 Openness
Two types of openness are important: non-proprietary and extensibility.
Public protocols are important because they make it possible for many software
manufacturers to build clients and servers that will be able to talk to each other.
Proprietary protocols limit the “players” to those from a single company and
thus limit the success of the protocol.
A system is extensible if it permits customisations needed to meet unanticipated
requirements. Extensibility is important because it aids scalability and allows a
system to survive over time as the demands on it and the ways it is used change.
2.5.6 Transparency
The final goal is transparency. We often use the term single system image to
refer to this goal of making the distributed system look to programs like it is a
tightly coupled (i.e., single) system.
This is really what a distributed system software is all about. We want the system
software (operating system, runtime library, language, compiler) to deal with all
of the complexities of distributed computing so that writing distributed
applications is as easy as possible.
Achieving complete transparency is difficult. There are eight types, namely:
Access Transparency enables local and remote resources to be accessed
using identical operations
Location Transparency enables resources to be accessed without
knowledge of their (physical) location. Access transparency and location
transparency are together referred to as network transparency.
Concurrency Transparency enables several processes to operate
concurrently using shared resources without interference between
them.
Replication Transparency enables multiple instances of resources to be
used to increase reliability and performance without knowledge of the
replicas by users or application programmers.
Failure Transparency enables the concealment of faults, allowing users
and application programs to complete their tasks despite the failure of
hardware or software components.
Mobility Transparency allows the movement of resources and clients
within a system without affecting the operation of users or programs.
26
Performance Transparency allows the system to be reconfigured to Distributed Operating
Systems
improve performance as loads change
Scaling Transparency Transparency allows the system and applications
to expand in scale without change to the system structure or the
application algorithms
2.6.1 Naming
A name is a string of characters used to identify and locate a distributed
resource.
An identifier is a special kind of name that is used directly by the computer
to access the resource.
For example the identifier for a Unix server would include at least (1) an IP
address and (2) a port number. The IP address is used to find the node that
runs the server and the port number identifies the server process on that
node.
Resolution is the process of turning a name into an identifier. Resolution is
performed by a Name Server. It is also called “binding” (as in binding a
name to a distributed service).
For example, an IP domain name (e.g., cs.ubc.ca) is turned into a IP address by
the IP Domain Name Server (DNS), a distributed hierarchical server running in
the Internet.
2.6.2 Communication
Getting different processes to talk to each other
Messages
Remote method invocation.
We talked last time about the importance of the goal of failure tolerance.
To build systems that can handle failures, we need a model that clearly
defines what a failure is. There are two key types of failures: Fail-stop and
Byzantine.
Fail-stop is a simplified failure model in which we assume that the only way
a component will fail is by stopping. In particular, a will never fail by giving
a wrong answer. 29
Advanced Topics in Byzantine failure is a more encompassing model that permits failures in
Operating Systems
which a failed node might not stop but might just start giving the wrong
answers. Techniques for dealing with Byzantine failure typically involve
performing a computation redundantly (and often in different ways with
different software). The system then compares all of the answers generated
for a given computation and thus detects when one component starts giving
the wrong answer. The ability to detect Byzantine failures is important for
many safety-critical systems such as aircraft avionics.
In this class we will assume failures are Fail-Stop; this is a common
assumption for distributed systems and greatly simplifies failure tolerance.
Clock Consistency
Maintaining a consistent view of time needed to order network events is
critical and challenging. This becomes further difficult when the nodes of
the distributed system are geographically apart. Let us study the scheme
provided by Lamport on Ordering of events in a distributed environment in
the next section.
If a is a message
m sent from
f P and b is the receiipt of that sam
me message in P ,
i j
then C (aa) < C (b).
i j
Im
mplementation Rules Reequired:
2..7 DIST
TRIBUTE
ED SYST
TEM STR
RUCTUR
RE
Thhere are threee main altern
native ways to
o structure a distributed application.
a E
Each
off them definees a differentt application
n model for wwriting distrributed progrrams.
Th
he three distrributed systeem applicatioon models arre:
Client / Seerver (and RPC)
R
Distributeed objects
Distributeed shared meemory.
Eaach model reequires a diff fferent set of “system” sooftware to suppport applicaations
wrritten in that style. This system
s softwware consists of a combinnation of operating
sy
ystem and run ntime-library y code and suupport from llanguages and compilers. What
alll of this codee does is transslate the distrributed featurres of the parrticular appliccation
model
m into thee sending annd receiving of o network messages.
m Beecause, remeember
th
hat the only way
w that nodees (workstations/PCs) cann communicaate in a distriibuted
sy
ystem is by seending and receiving
r meessages.
Figgure 2: Distrib
buted objects m
models
For exampple, in the piicture above,, a client program runnin ng can accesss local
object A and
a remote object
o B (conntrolled by the
t server noode) in exacttly the
same way y; the arrowss show flow of a proceddure call intoo the object and a
return from m it. The serrver can dessign B so thaat calls are tuurned into reemote
calls just like
l RPC (red d) or it can shhip some datta to the cliennt with the cllient’s
copy of thhe object an nd thus allow w some callls to run loccally on the client
(orange).
More on distributed
d obbjects later in
i the course.
The system
m implementts the illusion
n of shared memory
m and trranslates acceesses
to shared data
d into thee appropriatee messages.
To a proggram, the diistributed syystem lookss just like a shared-mem
mory
multiprocessor.
33
Advanced Topics in The advantage is that it is really easy to program: hides all of the details of
Operating Systems
distribution.
The disadvantage is that it often hides too much. As far as a program knows,
everything in its memory is local. But really, some parts of its memory are
stored on or shared with a remote node. Access to this remote data is very
SLOW compared with accessing local data. For good performance, a program
usually needs to know what data is local and what data is remote.
Another disadvantage is that it is very complicated to implement a distributed-
shared memory system that works correctly and performs well.
We’ll talk more about distributed shared memory towards the end of the
term.
This solution is not problem free. What if the token is lost? What if a process in
the ring ceases transmission? Nonetheless, it is at the root of a number of
interesting and useful distributed mutual exclusion algorithms. The advantage of
such distributed algorithms is that they do not rest on a central authority, and
thus, they are ideal candidates for use in fault tolerant applications.
An important detail in the token-based mutual exclusion algorithm is that, on
receiving a token, a process must immediately forward the token if it is not waiting
for entry into the critical section. This may be done in a number of ways:
Each process could periodically check to see if the token has arrived. This
requires some kind of non-blocking read service to allow the process to poll
the incoming network connection on the token ring. The UNIX FNDELAY
flag allows non-blocking read, and the Unix select() kernel call allows testing
an I/O descriptor to see if a read from that descriptor would block; either of
these is sufficient to support this polling implementation of the token passing
protocol. The fact that UNIX offers two such mechanisms is good evidence
that these are afterthoughts added to Unix after the original implementation
was complete.
The receipt of an incoming token could cause an interrupt. Under UNIX, for
example, the SIGIO signal can be attached to a socket or communications
line (see the FASYNC flag set by fcntl). To await the token, the process
could disable the SIGIO signal and do a blocking read on the incoming token
socket. To exit the critical section, the process could first enable SIGIO and
then send the token. The SIGIO handler would read the incoming token and
forward it before returning.
2.9.2
2 Rem
mote Procedure Calliing Mechaanism
A remote proccedure is uniiquely identiffied by the trriple: (prograam number, version
v
number,
n proccedure numbber). The pro ogram number identifies a group of related r
reemote proceedures, each of which haas a unique procedure number.n A prrogram
may
m consist of one or m more versionss. Each verssion consistss of a collecttion of
procedures
p w
which are avvailable to bee called remmotely. Versioon numbers enable
multiple
m versions of a RPC protocol to o be availablle simultaneo ously. Each version
v
contains
c a nuumber of proccedures that can be calledd remotely. Each
E proceduure has
a procedure number.
n
2.9.3
2 Impllementatioon of RPC
C
RPC
R is typicaally implemeented in one of two wayss:
1) Within a broader, moore encompasssing proprieety product.
2)
2 By a prog
grammer usiing a proprieetary tool to create
c client//server RPC stubs.
2.9.4
2 Conssideration
ns for Usagge
RPC
R is approopriate for cllient/server applications
a in which thee client can issue a
reequest and wait
w for the sserver’s response before continuing its i own processing.
Because
B mostt RPC implem mentations do
d not supporrt peer-to-peeer, or asynchrronous,
client/server
c interaction, RPC is no ot well-suiteed for appliications invvolving
distributed
d ob
bjects or objeect-oriented programminng.
42
Asynchronous and synchronous mechanisms each have strengths and weaknesses Distributed Operating
Systems
that should be considered when designing any specific application. In contrast to
asynchronous mechanisms employed by Message-Oriented Middleware, the use
of a synchronous request-reply mechanism in RPC requires that the client and
server are always available and functioning (i.e., the client or server is not blocked).
In order to allow a client/server application to recover from a blocked condition,
an implementation of a RPC is required to provide mechanisms such as error
messages, request timers, retransmissions, or redirection to an alternate server.
The complexity of the application using a RPC is dependent on the sophistication
of the specific RPC implementation (i.e., the more sophisticated the recovery
mechanisms supported by RPC, the less complex the application utilising the
RPC is required to be). RPC’s that implement asynchronous mechanisms are
very few and are difficult (complex) to implement.
When utilising RPC over a distributed network, the performance (or load) of the
network should be considered. One of the strengths of RPC is that the synchronous,
blocking mechanism of RPC guards against overloading a network, unlike the
asynchronous mechanism of Message Oriented Middleware (MOM). However,
when recovery mechanisms, such as retransmissions, are employed by an RPC
application, the resulting load on a network may increase, making the application
inappropriate for a congested network. Also, because RPC uses static routing
tables established at compile-time, the ability to perform load balancing across a
network is difficult and should be considered when designing a RPC-based
application.
Tools are available for a programmer to use in developing RPC applications over
a wide variety of platforms, including Windows (3.1, NT, 95), Macintosh, 26
variants of UNIX, OS/2, NetWare, and VMS. RPC infrastructures are implemented
within the Distributed Computing Environment (DCE), and within Open Network
Computing (ONC), developed by Sunsoft, Inc.
2.9.5 Limitations
RPC implementations are nominally incompatible with other RPC
implementations, although some are compatible. Using a single implementation
of a RPC in a system will most likely result in a dependence on the RPC vendor
for maintenance support and future enhancements. This could have a highly
negative impact on a system’s flexibility, maintainability, portability, and
interoperability.
Because there is no single standard for implementing a RPC, different features
may be offered by individual RPC implementations. Features that may affect the
design and cost of a RPC-based application include the following:
support of synchronous and/or asynchronous processing
support of different networking protocols
support for different file systems
whether the RPC mechanism can be obtained individually, or only bundled
with a server operating system.
Because of the complexity of the synchronous mechanism of RPC and the
43
Advanced Topics in proprietary and unique nature of RPC implementations, training is essential even
Operating Systems
for the experienced programmer.
Check Your Progress 1
1) How is a distributed OS different from Network OS? Explain.
........................................................................................................................
........................................................................................................................
........................................................................................................................
A distributed operating system takes the abstraction to a higher level, and allows
hides from the application where things are. The application can use things on
any of many computers just as if it were one big computer. A distributed operating
system will also provide for some sort of security across these multiple computers,
as well as control the network communication paths between them. A distributed
operating system can be created by merging these functions into the traditional
operating system, or as another abstraction layer on top of the traditional operating
system and network operating system.
Any operating system, including distributed operating systems, provides a number
of services. First, they control what application gets to use the CPU and handle
switching control between multiple applications. They also manage use of RAM
and disk storage. Controlling who has access to which resources of the computer
(or computers) is another issue that the operating system handles. In the case of
distributed systems, all of these items need to be coordinated for multiple
machines. As systems grow larger handling them can be complicated by the fact
that not one person controls all of the machines so the security policies on one
machine may not be the same as on another.
Some problems can be broken down into very tiny pieces of work that can be
done in parallel. Other problems are such that you need the results of step one to
do step two and the results of step two to do step three and so on. These problems
cannot be broken down into as small of work units. Those things that can be
broken down into very small chunks of work are called fine-grained and those
that require larger chunks are called coarse-grain. When distributing the work to
be done on many CPUs there is a balancing act to be followed. You don’t want
the chunk of work to be done to be so small that it takes too long to send the work
to another CPU because then it is quicker to just have a single CPU do the work,
You also don’t want the chunk of work to be done to be too big of a chunk
because then you can’t spread it out over enough machines to make the thing run
quickly.
In this unit we have studied the features of the distributed operating system,
architecture, algorithms relating to the distributed processing, shared memory
concept and remote procedure calls.
47
Advanced Topics in
Operating Systems UNIT 3 MOBILE OPERATING SYSTEMS
Structure
3.1 Introduction
3.2 Objectives
3.3 Mobile Devices – An Introduction
3.3.1 Characteristics of Mobile Devices
3.3.2 Data Input Mechanisms for Mobile Devices
3.3.3 Wireless Communication
3.3.4 Mobile Operating System
3.3.5 Types of Processors Used by Mobile Devices
3.3.6 Limitations of Mobile Devices
3.1 INTRODUCTION
In the earlier units we have studied about the functions of traditional and desktop
operating systems and in this unit we will study about the Mobile devices and
Mobile Operating Systems. Earlier mobile communication technologies were
dominated by vertically integrated service provision which are highly bounded
mainly to voice and short message services that are organized in a monopolistic
competition between few mobile virtual network operators, service providers
and enhanced service providers.
In the recent years, however, radical change driven by advancements in technology,
witnessed the introduction and further development of smart phones where the
user can get access to new applications and services by connecting to the device
manufacture’s application stores and the like. These smart phones have added
many features of a full-fledged computer: high speed processors, large storage
space, multitasking, high-resolution screens and cameras, multipurpose
communication hardware, and so on. However, these devices market is
dominated by a number of different technological platforms, including different
operating systems (OS) and application development platforms, resulting in a
variety of different competing solutions on the market driven by different actor.
This unit is focused on mobile devices, their characteristics and mobile operating
48 systems.
Mobile Operating Systems
3.2 OBJECTIVES
After going through this unit, you should be able to:
define and identify various mobile devices;
understand the characteristics of mobile devices along g with their constraints;
define the mobile OS and identify its functionalities, and
describe various design issues of mobile OS.
Mobile phones typically implement a 12-digit keypad. This is very intuitive and
effective for numerical input but cumbersome and awkward for entering text.
This is because each key on a keypad represents three characters. Users have to
press a key multiple times to enter a single character. Since mobile phones are
primarily designed for voice usage, it is unlikely that the keypad will change
anytime soon. That said, there are technologies available that make entering text
easier. One of these is called T9, which stands for Text on 9 Keys. This is a
predictive text input technology that allows a user to input words by pressing
only one button per letter. T9 translates the button press sequences into words. It
does not work in all cases, but when it does, it is about twice as fast as using
traditional multi-tap systems. America Online, the owner of T9, estimates that it
is accurate 95 percent of the time.
Device manufacturers are constantly looking for ways to make keypad text entry
more effective. Toggle sticks, rollers, and touch screens will help to alleviate this
problem in some areas, but do not expect fast data entry to be a reality on a
keypad-driven device anytime soon.
b. Physical Keyboard Input
Even with the advances being made in other forms of data input, the keyboard
remains the most efficient and easy to use. Mobile devices have many ways to
take advantage of keyboard data entry. Laptops and handheld PCs come equipped
with physical keyboards, while the smaller palm-sized PDAs often support
keyboards as a peripheral. These keyboards are usually attached as a clip-on unit
or via a cable, but wireless connections are also an option. In addition, most
PDAs have PC companion software, allowing the user to enter data such as contact
information on the PC. Some handheld devices have taken the step of
incorporating a keyboard into the unit itself. This is accomplished with small
thumb-based keyboards at the bottom of the unit. Research in Motion (RIM) was
the first to incorporate this concept into its BlackBerry devices. With its
revolutionary design, RIM has attracted a wide variety of users to its devices,
prompting other companies, including Handspring and Sharp, to adopt the thumb-
sized keyboard as the means for data input.
c. Pen-Based Input
One of the breakthroughs for handheld devices was the introduction of touch
screens for pen-based input. This allows a user to enter data using a stylus, without
requiring any form of physical keyboard or keypad. Several pen-based input
mechanisms are available. Deciding which ones to implement will depend on
the mobile operating system and device being used. The most common types of
pen-based input are:
Soft keyboards. The most approachable method of entering text on
mobile devices is by using a soft keyboard, a keyboard displayed on the
screen. Users enter data by pressing “keys”, just as they would on a
physical keyboard. This method is very easy to learn and use, but it is
also takes up screen space and can be limiting in terms of input speed. It
is often used as a backup mechanism when other forms of data input are
not effective.
51
Advanced Topics in Character recognition. Character recognition works by interpreting
Operating Systems
which letters a user is entering on the screen. There is usually a specific
area on the screen for users to construct the characters. The Windows
CE operating system from Microsoft provides this capability. Software
runs locally on the device to do the interpretation. The letters have to be
constructed fairly accurately for them to be understood. This is usually
not a problem for small amounts of data, but can be a challenge for users
who need to enter data quickly. They often find the characters difficult to
write, leading to mistakes.
Graffiti. Palm OS introduced a new form of character recognition based
up on simple character-set called Graffiti. The Graffiti characters allow
for quicker data input since the letters are easy to input and recognize.
There is a learning curve involved, but once Graffiti is mastered, data
can be input quickly with few errors.
Handwriting recognition. Some forms of handwriting recognition work
by taking screen captures of the inputted text, while others actually
interpret written characters. The interpretation solutions take character
recognition to a new level. Instead of being able to interpret only a defined
set of characters with predetermined strokes, handwriting recognition
attempts to interpret a user’s personal style of text entry. This requires
sophisticated software and powerful hardware to do the analysis.
Microsoft is implementing forms of handwriting recognition on its Tablet
PC platform.
d. Voice Input
Voice input is both effective and easy to use. Simple voice commands, such as
initiating a call or looking up a contact, can be executed directly on the mobile
device. This works by prerecording voice commands into the device. When a
voice command is entered, it is compared to the recorded message and executes
the corresponding action. Many mobile phones come equipped with this feature.
Let us study on the processors those are used the mobile devices. In the recent
days most of our devices are come with the Octa-core or Quad-core processors.
In the processors the main element is the core that reads and executes instructions.
Devices began with a single-core processor, but processor companies have created
more powerful devices by including more cores in one device that led to dual-
core devices. Soon there were quad-core processors (as in four cores), and now
there are hexa- (six) and octa-core (eight) smartphones and tablets.
Benefits of Multiple Cores
The more cores, faster they can divide the work you’re requesting the phone to
do. So the benefits of a multi-core are it enhances your device performance and
your apps loads quickly on your device. You can easily capture high-quality photos
and videos then browse your collection without pausing the system.
Some Popular Processors for Mobile Devices
i. Qualcomm Snapdragon : It is a US based company, Qualcomm was the
first brand that introduce CDMA technology in the market and actively
involved in technology related to semiconductors designing for Mobile
devices, tracking devices, satellite phones, Virtual Reality, wireless charging
etc. It is widely known for its Snapdragon brand which is responsible for
releasing mobile processors and LTE modems. It first claim to fame in
processor market when it released the first 1 Ghz processor that time average
speed of most smartphones was only 512 Mhz. The processor comes under 4
series (220, 400, 600 and 800). Qualcomm Snapdragon processors are known
for its performance. The processor handles multitasking very well and can
handle heavy and intensive processing which is especially good for gaming.
The presence of inbuilt Adreno graphics matches the performance of
processor. Snapdragon processors also produce less heat compared to other
processors. Generally Snapdragon processors are costlier than other
processors. Qualcomm also make processors are also used for wearable
platforms, automotive platforms, embedded platforms, vision intelligence
platforms and extended reality platforms.
ii. Apple Mobile Processors: Apple does not manufacture any microprocessors.
Instead, they make contracts with processor manufacturing companies mainly
Samsung and TSMC for making custom built processors that suits their design
and performance expectations. The processor comes under
a. A- Series: The A series is a family of “System on Chips” (SoC) used in
iPhones, iPad, iPod touch & Apple TV. They are designed by Apple and
manufactured by Samsung & TSMC. They integrate CPU, GPU, Cache
memory and other electronics necessary to provide mobile computing
functions within a single physical package.
b. S- Series: The S series is a family of “System in Package” (SiP) used in
Apple watch. They are designed by Apple and manufactured by Samsung.
c. T- Series: The T-Series is designed to use in TouchID sensors in MacBook
Pro. The only version released till now is Apple T1. 55
Advanced Topics in d. W-Series: Apple W series is used in headphones for wireless audio
Operating Systems
connectivity. The series is currently in Apple W1 which is used in wireless
headphones and AirPods.
e. H-Series: The Apple H1 chip was first used in the 2019 version of
AirPods, and was later used in the Powerbeats Pro, the Beats Solo Pro
and the AirPods Pro. Specifically designed for headphones (“H” in a
model number stands for headphones), it has Bluetooth 5.0, supports
hands-free “Hey Siri” commands, and offers 30 percent lower
latency than the W1 chip used in earlier AirPods.
f. M-Series: The M1 chip, Apple’s first processor designed for use in Macs,
is manufactured using TSMC’s 5 nm process. It was announced on
November 10, 2020, and is used in the M1 MacBook Air, Mac mini, and
MacBook Pro (2020).
iii. Intel Atom and Core M Processors: Intel is an American multinational
company synonymous with PC and microprocessors. Atom is the brand name
given for the low power consuming and low cost 32 and 64 bit chips
manufactured for using in smartphones and tablet devices.Intel processors
are based on X86 architecture which is powerful than ARM, but consume
more power compared to ARM architecture. Intel Atom processors are
currently in Atom X5 and X7 series. These chips are 64 bit Quad core
processors in 14 nanometer size with speeds up to 1.6 GHz that can be scaled
up to 2.4 Ghz.Intel also released Intel Core M microprocessors which are
ultra low-voltage designed for ultra-thin notebooks, mobile devices and 2 in
1 convertibles. The processor consumes less 4.5 watts or less power making
it ideal for long battery life. These are dual core processors with speeds around
1.5Ghz which can be scaled to 3.2 GHz speeds. Intel Core M processors
offer 40% boost in CPU and graphics performance than previous versions.
iv. Nvidia Tegra Processors:Nvidia Corporation is an American based company
technology company which specializes in making processing units for
graphics, gaming units and mobile devices. Nvidia develops chips for
smartphones, tablets and mobile devices under the brand Tegra.Tegra
processors are built on 64 bit ARM architecture. Tegra till now have gone
through Tegra 1, 3, 4, 4i, K1, X1 series. The process is Quad Core with 256
GPU cores capable of 4K video capabilities. The chips are built on 20 nm
technology. The processor is currently used in Nvidia SHIELD Android TV.
Tegra processors used in Andorid TVs, smartphone and tablets.
v. Samsung Exynos: Exynos is a brand of Samsung Electronics which makes
processors based on ARM architecture. Exynos processors are manufactured
in the series of ARMv7 and ARMv8 SoCs. Exynos 8 Octa 8895 is the latest
from Exynos. The processor is equipped with Octa-Core on 64-bit ARM
architecture with Mali GPU. The processor is capable of running at 2.3 GHz
speed with support for 3D gaming, 4K UHD resolution support. The chips
are 10 nm technologies. The processor is used in Galaxy S8 and S8+ phones.
You can study in detail on Android in Block-4 where Case Studies are discussed.
iOS
You can study in detail on iOS in Block-4 where Case Studies are discussed.
Symbian
Symbian operating system is the most popular operating system used in most
Smartphones and mobile phones today. The heritage of Symbian OS begins with
some of the first handheld devices. This operating system began its existence in
1988 as SIBO (an acronym for ’16-bit organizer’). SIBO ran on computers
developed by Psion Computers, which developed operating system to run on
small footprint devices. It was designed with specific criteria that can be
characterized by event-driven communications, using client-server relationships
and stack-based configurations. Symbian OS model follows layered approach
and contains UI frame work layer, Application services layer, Base service layer
and kernel services and hardware interface layer. Symbian OS has a micro kernel
architecture that provides robustness, availability and responsive.
Client-server describes the relation between two computer programs. The client
program sends a service request to the server program. The server program fulfils
the request. The Symbian operating system is developed using C++ programming
language.
The Symbian operating system is a mobile operating system that was specially
built to run on a Smartphone platform. It fits in the memory of a mobile phone
because of its compatibility. It is considered as a full-fledged operating system.
Windows Mobile
Linux
Linux is unique among the other operating systems. This is because its
development is driven by a community of developers rather than by a single
company such as Symbian operating system in Nokia phones and blackberry OS
in blackberry phones. According to ARCchart, the Linux operating system
supports more processors than other operating system, though the most popular
phone models still use the Symbian operating system. However, Linux is an
open source operating system, where in, the developers constantly change and
update it even at the kernel level platforms.
Smartphones based on the open source Linux operating system have emerged in
the market. There are many advantages to using an open-source operating system
like Linux. No cost and the opportunity to tap into the Linux open source
community are appealing. This has made Linux grow, not only for the server and
PC market space, but also in the embedded device area including handheld
computers. For example, Motorola that is a notable supporter of Linux has released
the A760 Smartphone based on this operating system.
The comparison of Symbian, iOS and Android are given below in Table 2.
67
Advanced Topics in Table 2: Comparative Chart of Symbian, iOS and Android
Operating Systems
PARAMETERS SYMBIAN iOS ANDROID
3.9 SUMMARY
In this unit, mobile devices and mobile operating systems were discussed.
Mobile devices are the devices that are easily transported and typically are
handheld and powered by a battery. They would have unique challenges in their
design to enable usability, ruggedness, and reliability. Characterized by relatively
lightweight and small screen size, they span a wide range of device types and
applications, including mobile phones and tablets. Mobile devices also include
custom devices designed for specific use cases, such as military, medical, or
industrial applications where particular peripherals, security, certification, or
regulatory requirements must be fulfilled.
3.10 SOLUTIONS/ANSWERS
Check Your Progress 1
1) Sailfsh OS is the logical evolution of MeeGo, an operating system developed
by Nokia, based on Linux and in order to attack the market of smart phones
and tablets. When Meego was dropped, some of their workers left to form
Nokia Jolla, one covered by the Finnish company, which has renamed the
system as Sailfsh OS. The operating system has its own programming
language (Qt / QML), although accepted through their respective sdks
developing apps in HTML5 (Cordoba Qt) and Java (Android apps).
The architecture is similar to what we have seen in most mobile operating
systems: Linux kernel, a layer of components (based on Mer), with the
interface middleware and applications. Sailfish is a modern and secure
operating system combining the Linux Kernel for a particular platform use.
It is a general purpose linux based operating system.
It is built on the heritage of MeeGo. Sailfish is developed by Jolla in permanent
cooperation with the Sailfish community. The Sailfish community makes
development requests and decides development priorities by voting. The Mer
project receives contribution from Jolla community and Mer contributes
middleware for jolla thereby assuring compatibility of both projects. It’s like
a classic Linux distribution with the great addition of the Jolla crafted Sailfish
UI. There’s no buttons on Sailfish devices, everything is handled with simple
gestures, supported by an appealing design style. It is really a very interesting
platform for both users and developer. Sailfish used in theJjolla smart phone
and other licensees. Sailfish OS can run Android applications through a
proprietary compatibility layer.
2) (a) HarmonyOS
Huawei unrevealed HarmonyOS 2.0 in 2020. Huawei has planned to relase
it as an open-source platform worldwide. It will open up and share its core
capabilities in areas like connectivity, cameras and AI. It will work closely
with ecosystem partners to deliver apps and services that provide consumers
good experience.
HarmonyOS is completely different from Android and iOS. It is a microkernel-
based, distributed OS that delivers a smooth experience across all scenarios.
It has a trustworthy and secure architecture, and it supports seamless
collaboration across devices. Following are some of the features of
HarmonyOS:
Seamless experience
Smooth performance
More Secure
All-in-one
70
(b) KaiO
OS M
Mobile Operatin
ng Systems
Fig 1: KaiO
OS Architecturre
Core:Thee underlying platform thaat consists off the Web appplication runntime,
i.e. Gecko
o, plus the hardware
h adaaptation layeer and a feww other suppoorting
module
App Proffile: A collection of built-in web appps, which reepresents thee user
interfacingg functions of
o KaiOS forr a given devvice form facctor.
3..11 FUR
RTHER READIN
R GS
1)) Milan Millenkovic, Op
perating Systtems, Conceppts and Desig
gn, TMGH, 22000.
2)) D.M. Dhaamdhere, Operating Systems, A conceept-based appproach, TM
MGH,
2002.
3)) Andrew S Tanenbaum
m, Herbert Bos, Modern Operating
O Sysstems, 4th Ediition,
Pearson , 2015.
2
4)) Naresh Chhauhan, Prin
nciples of Opperating Systtems, Oxford
d Press, 20144. 71
MCS--203
O
Operatiing Systeems
In
ndira Gandhi
Naational Open University
U
Scchool of Compu uter and
In
nformation Scieences
Block
B
4
CASE
C STU
UDIES
UNIT
U 1
Case
C Studyy 1 – Win
ndows 10 5
UNIT
U 2
Case
C Study
y 2 – LIN
NUX 21
UNIT
U 3
Case
C Study
y 3 – And
droid 45
UNIT
U 4
Case
C Studyy 4 – iOS
S 63
PROGRAMME/COURSE DESIGN COMMITTEE
March, 2021
© Indira Gandhi National Open University, 2021
All rights reserved. No part of this work may be reproduced in any form, by mimeograph or any other
means, without permission in writing from the Indira Gandhi National Open University.
Further information on the Indira Gandhi National Open University courses may be obtained from the
University’s office at Maidan Garhi, New Delhi-110068.
Printed and published on behalf of the Indira Gandhi National Open University, New Delhi by the
MPDD, IGNOU, New Delhi
Laser Typesetting : Akashdeep Printers, 20-Ansari Road, Daryaganj, New Delhi-110002
Printed at :
BLOCK INTRODUCTION
This block introduces you to the Case Studies on Windows 10, Linux, Android and
iOS.
The block is organized into 4 units.
Unit 1 covers the Windows 10
Unit 2 covers the LINUX
Unit 3 covers one of the most popular mobile operating system; the Android
Unit 4 covers another most popular mobile operating system; the iOS.
Case Studies
4
Case Study – Windows 10
UNIT 1 CASE STUDY - WINDOWS 10
Structure
1.0 Introduction
1.1 Objectives
1.2 Features of Windows 10
1.3 Evolution of Windows 10
1.4 Windows 10 Editions
1.5 Windows OS Components
1.6 Process Management in Windows 10
1.6.1 Processes and Threads
1.6.2 Scheduling
1.6.3 Interprocess Communication
1.7 Memory Management in Windows 10
1.7.1 Memory Representation
1.7.2 Physical Memory Organization
1.7.3 Virtual Memory Organization
1.7.4 Demand Paging
1.7.5 Memory Compression
1.8 File System Management in Windows 10
1.8.1 Directory Management
1.8.2 Disk Management
1.8.3 File Management
1.8.4 File Compression
1.9 Summary
1.10 Solutions / Answers
1.11 Further Readings
1.0 INTRODUCTION
Anoperating systemisset ofprograms thatact asan interface between userand hardware.
It is a type of system software that provides various low level functionalities like
process management, memory management, I/O management, file management,
scheduling. Examples ofpopular operating system are Windows, Linux,
Unix,Android, iOS, Mac.
Operating system is used to perform two major activities-
Interfacing user with hardware
Management of Resources
Windows 10 is one of the most popular and latest operating system of Microsoft. It is
introduced with the concept of “Universal apps”, which provides apps designed to
work for multiple platforms like personal computers, smartphones, Xbox One consoles,
laptops and other compatible devices. It is designed for various platforms. 5
Case Studies Windows is widely used operating system for desktop users. The various reasons for
its popularity among users are-
Easy to use interface
High availability of compatible software
Provides support for new hardware
Provides Plug and Play feature
Although it is popular among desktop users, it has several disadvantages over other
operating systems.
It is proprietary
It is closed source
It is susceptible to virus hence not secure
Lacks good technical support
Resource requirements are high
In this unit, we will study about the features, evolution, process management, memory
management and file management in Windows 10 Operating System.
1.1 OBJECTIVES
After going through this unit, you should be able to:
Know about the features of Windows 10
Understand various editions of Windows 10 operating system
List various components of Windows
Describe about Process and memory management in Windows 10
Describe how files and disk are managed
Know about the compression used in Windows 10
1.5 WIND
DOWS OS
O COMP
PONENTS
S
Windows
W operrating system m has two moddes for its opeeration – kern nel mode andd User
mode.
m User appplications runn in user modde and system m operations ru uns in kernel m
mode.
Appplications thhat run in kernel
k mode shares
s single virtual addrress space w while a
diffferent privatte virtual addrress space is allocated
a to eeach applicatiion in user moode.
When
W an appliication is starrted in user mode,
m a proceess is created
d by windowss and a
prrivate virtual address space is alloccated. Since the address space is pprivate,
ap
pplications can
annot access or o modify daata belongingg to other app plications. Sim
milarly
theey also cannoot access virttual address reserved
r for ooperating sysstem. Also if due to
so
ome reason ann application n crashes, opperating systemm and other application
a w
will not
bee affected.
On n the other hand,
h single virtual
v addreess space is sshared by proocesses runnning in
keernel mode. Itt means that processes
p are not
n isolated by
b each other. Drivers are uusually
ruun in kernel mode.
m Internaal componentts of window ws operating system
s is shoown in
fig
gure 1.
Fig 1: Window
ws Componen
nts (Source: doccs.microsoft.coom)
Un
niversal Win
ndows Platfoorm Apps
Un niversal W ind
dows P latform
m(UWP) is introduced
i inn W indows 10. It is com mmon
plaatform that can be used foor different tyypes of devices that runs windows
w 10. In
I this
saame core AP PI is used foor all devicess. The apps are written in C++/WinR RT or
C+ ++/CX and can
c access Win32
W API whhich is implem mented by all window
w 10 deevices.
Foor user interfa
face DirectX X, XAML or HTML H is used. If apps need to be dessigned
Case Studies
1..6 PRO
OCESS MANAGE
M EMENT IN
I WIND
DOWS 100
1.6.1
1 Proocesses and T
Threads
A program inn execution is called a process.p A prrocess containns informatioon like-
unique
u process identifierss, virtual adddress space, priority, env vironment vaariables,
working
w set size, executaable code annd security ccontext. Inittially processs starts
execution
e witth a single thhread, known n as primary thhread but lateer additional threads
t
can
c be createed by primary ry thread. Eveery thread mmaintains infoormation likee unique
thhread identiffier, priority, local storagee, data structture to save thread conteext and
security conttext. Thread context conntains user sstack, kernell stack, and set of
reegisters. Alll threads of a single proocess shares system ressources and virtual
address
a spacee.
In
n windows multiple
m threeads belongiing to differrent processees can be exxecuted
simultaneouslly and createss the effect off simultaneouus execution for single proocessor
syystem. Hencee it is called multitasking.
m A window
Also ws follows preemptive apprroach of
scheduling heence time slicce is allocatedd to each threead. After thee time slice elapses,
e
swwitching is do
one to anotheer thread and system savess the context of
o preempted thread.
Context
C of neww thread is looaded for execcution.
1.6.2
1 Scheduling
Scheduling
S deecides the ordder in which th
hreads will bee executed. Sccheduling of threads
iss done by givving priorities in range the between
b 0 to 31, where 0 represents
r miinimum
and
a 31 represeents maximum m priority. Th
hreads with same priority are treated ass equal.
Time
T slices is assigned to tthread in rouund-robin fashhion to high h priority thhreads.
Factors
F to deteermine prioriity of thread are:
a
1. Priorrity class off process – process cann belong to any of the class -
IDLEE_PRIORITY Y_CLASS, BELOW_NO ORMAL_PR RIORITY_C CLASS,
NORRMAL_PRIOR RITY_CLAS SS,ABOVE_N NORMAL_P PRIORITY_C CLASS,
HIGHH_PRIORITY Y_CLASS, REALTIME E_PRIORITY Y_CLASS
2. Priorrity level of thhread – prioritty levels of thr
hread within a process can be
b any
one of
o the followinng- THREAD D_PRIORITY Y_IDLE,
THRREAD_PRIOR RITY_ LOW WEST
THRREAD_PRIOR RITY_BELO OW_NORMA AL,
THRREAD_PRIOR RITY_NORM MAL
THRREAD_PRIOR RITY_ABOV VE_NORMA AL,
THRREAD_PRIOR RITY_HIGH HEST
Priority of a thread is formed by combining these to priorities- priority class of process Case Study – Windows 10
and priority level of thread. This is called base priority of thread.
Priority Boosts
When threads of higher priority gets execute every time, the system can suffer form
the problem of starvation. To solve this problem Windows uses the concept of
dynamic priorities. Initially priority of each thread is initialized with base priority.
The system can later change the priority of threads so that no thread gets starved.
The threads having base priority between 0 to 15 can receives priority boosts. Each
time when a thread completes a time slice, its priority is reduced by one level by the
scheduler until thread gets its base priority back. Once the base priority is reached, the
priority is not changed further.
User mode scheduling
Applications can also schedule their own threads using user mode scheduling
mechanism. In this application can switch from user mode and gain control of
processor without involving system scheduler. It is used for applications that require
high performance to execute threads concurrently. This service is available only for
64-bit versions. Here the scheduler component must be implemented by the
application
1.6.3 Interprocess Communication
Interprocess communication is the mechanism which facilitates communication and
sharing of data among processes or applications. Here applications requesting for a
service can be called client and the application serving the request can be called server.
Also applications canactas bothclient and server. The various IPC mechanisms available
in windows are:
i. Clipboard
It is a loosely coupled medium for sharing of data. All the application
needs to agree on common data format. Whenever a cut or copy operation
is performed on data, it is put on clipboard which can then be used by other
applications.
ii. COM
Software that uses component object model (COM) can access and
communicate with variety of components. It allows one application to be
embedded or linked with other components. Applications that use OLE
make use of this.
iii. Data Copy
This allows sending of information from one application to another using
windows messaging. The receiver must be able to identify the sender and the
format of information.
iv. DDE
Dynamic data exchange is a protocol that allows variety of data formats to be
exchanged. It is extension of clipboard. Unlike clipboard it continuesto function
without need of further interaction after one time data exchange.
v. File Mapping
11
In this, file is treated as block of memory that can be shared by processes.
Processes that want to share this file gets a pointer to its memory location
Case Studies through which they can access or even modify file contents. Processes must
provide a synchronization mechanism to prevent corruption of data.
vi. Mailslots
Mailslots are used to send messages (one way) over network. Process that
creates mailslot is called mail slot server. The client writes or appends the
message in maislot and sends it to mail slot server. For two way
communication multiple mailslots can be created. They can also be used to
broadcast message across computers in network domain.
vii. Pipes
Two types of pipes can be used – anonymous or named.
Anonymous pipes are generally used for transfer of data between related
processes like parent child. Read write pipes should be created by each of
the processes to share data.
Named pipes are used between processes on different systems or to transfer
among unrelated processes. Server creates pipes and communicates it to
clients. Data can be exchanged once both get connected to pipe.
viii. RPC
Remote procedure call is a mechanism used to call remote functions which
can be between processes of same or different machine. It also allows data to
be converted for different hardware architectures. It is used for high
performance applications that are tightly coupled.
ix. Windows Sockets
It is an interface used for communication between sockets. It enables data to
be transmitted independent of network protocol and hence it is called
protocol independent.
Commit memory for a process is the amount of memory reserved by operating system
which is usually equal to the page file size required by a process. This memory is not
allocated until it is necessary to page out a process’s private working set from RAM to
page file. Virtual memory required by the system from page file is hence equal to the
sum of all process’s commit memory. However windows allows user to modify page
file and virtual memory size.
During bootup process, operating systemcreates two dynamic pools in physical memory
for kernel components. These pools are paged and non-paged pools.
Paged pool –this is the physical memory allocated for kernel components
that can be later written to disk when not required.
Non-paged pool –this is the physical memory allocated for kernel components
or objects that should always remain in physical memory compulsorily but
can optionally stored in disk.
1..7.5 Mem
mory Comp
pression
Windows
W 10 memory
m man nager perforrms memory compression by compreessing
inffrequently useed memory pages
p instead of
o writing theem on disk. Thhis reduces nuumber
15
Case Studies ro
oom for morre processes to t be kept in memory
m and hence allowiing more taskks to be
executed
e simu ultaneously. As compareed to previouss versions wiindows 10 writes
w to
disk
d only 50 % of the timee. Windows 10 also perforrms simultaneeous decomppression
of
o data in parrallel to readinng data by usiing multiple C
CPU cores. This
T happens because
b
of
o reduced nuumber of readds and writess. The amounnt of memoryy compressedd by the
system can bee checked in ttask managerr.
1.8
1 FILE
E SYSTE
EM MAN
NAGEME
ENT IN WINDOW
W WS 10
File
F system enable
e data or files to bee stored and retrived from m storage loccations.
Naming
N convventions, form
mats for path hs are also sppecified by file
f system. Storage
S
components
c in windows ffile system arre – files, direectories and volumes.
v A file is a
group
g of relaated data. A directory is collection oof files and directories
d stoored in
hierarchy.
h A volume
v is alsso a collection of files and directories.
1.8.1
1 Direectory Maanagementt
The
T number of o files in a diirectory is lim
mited by the siize of the disk where direcctory is
stored. The lin nk between tthe directory and files witthin directoryy is implemeented as
directory
d enttry table by NTFS file syystem. One or more entriees are createdd in this
taable for each file in directoory. Additional entries creaated for a filee (more than one)o are
called
c hard linnks. Any numbmber of hard linnks can be creeated for a fille. Whenever a file is
created,
c its en
ntry is added into table. Siimilarly when a file is mooved to directtory, its
entry
e is createdd as moved fille. When a filee is deleted, itts entry is alsoo deleted from
m table.
1.8.2
1 Disk
k Managem
ment
A hard is diviided into onee or more parttitions, whichh are logical regions
r and created
c
when
w user form mats hard diskk. Multiple paartitions makees file managem
ment easy. In storage
tyypes there aree two types oof disk- basic and dynamicc disk.
(ii) Basic disk k : Basic diskk contains priimary partitioon and logicaal drives. It suupports
Master Bo oot Record paartitionstyle(liikeolder winddows versions)) and GUID partition
p
table. In th
he traditionall MBR schem me, four primaary partitions or
o three prim
mary and
one extennded can be created.
c Alsoo one or moree logical drivves can be creeated in
extended partition. Thhe extended partitions
p shouuld be contiguuous. The paartitions
are formaatted to createe volume. Onee or more voluumes can be created
c with a single
partition. Partitions whhich are not formatted
fo cannnot be used for
fo storage.
Check Your Progress 1
1) List the important new features of WINDOWS 10 Operating System.
........................................................................................................................
........................................................................................................................
........................................................................................................................
........................................................................................................................
1.9 SUMMARY
In this unit a case study of Windows 10 is presented. The various operating system
functions like- Processmanagement, memory management and file Systemmanagement
are discussed in details. Also various features newly added in Windows 10 operating
system and various available versions introduced are also mentioned. In this unit, we
also discussed several theoretical concepts on Windows 10 in detail, often useful in
your lab for practice.
18 Improved Notifications
Tablet Experience Case Study – Windows 10
Cortana
Universal Print
Virtual Desktop
MS Tunnel Gateway
EndpointAnalysis
Microsoft 365 Apps
Productivity Score
2) Windows 10 includes Windows Security, which provides the latest antivirus
protection. Your device will be actively protected from the moment you start
Windows 10.
Firewall and network protection: Manage firewall settings and monitor what’s
happening with your networks and internet connections.
Device security. Review built-in security options to help protect your device
from attacks by malicious software. 19
Case Studies Device performance and health: View status info about your device’s
performance health, and keep your device clean and up to date with the latest
version of Windows 10.
Kids OnlineActivity Protection: Keep track of your kids’online activity and
the devices in your household.
20
Case Study – Windows 10
UNIT 2 CASE STUDY - LINUX
Structure
2.1 Introduction
2.2 Objectives
2.3 Linux Operating System
2.4 Evolution of Linux
2.5 Characteristics of Linux
2.6 Linux Kernel
2.7 Fundamental Architecture of Linux
2.8 Process Management in Linux
2.9 Memory Management in Linux
2.10 Linux File System
2.11 Security Features in Linux
2.12 Windows Vs Linux
2.13 Summary
2.14 Solutions/Answers
2.15 Further Readings
2.1 INTRODUCTION
Operating system is system software, which acts as an interface between user
applications and hardware devices such as input/output devices, memory, file system,
etc. It schedules both type of tasks, systems and users’, and provides common core
services such as a basic user interface. The two major goals of any operating system
(OS) are:
Convenience: It transforms the raw hardware into a machine that is more
accessible to users.
Efficiency: It efficiently manages the resources of the overall computer system.
Operating system consists of the following components for achieving the goals:
Kernel: The main task of the kernel is to optimize the usage of the hardware,
running the required programs, satisfying the user’s requirements.
Application Programming Interface (API): A collection of rules,
which describes how services have to be required from the kernel, and
how we receive the answer from it.
Shell: Its’ task is the interpretation of commands. The shell can be command
line (CLI - Command Line Interface, such as DOS), or graphic - GUI -
interface (e.g.: Windows)
Services and Utilities: These supplementary programs enhance the user’s
experience (e.g.: word processors, translator programs) and are not
inseparable parts of the system. 21
Case Studies Operating systems may be categorized into various types based on their functionality
such as single user single task operating systems, single user multitasking operating
systems, multi-programmed operating system, multiuser operating systems, distributed
operating systems, network operating system, multiprocessor operating system, real
time operating systems and embedded operating systems. Disk Operating System
(DOS), Windows, UNIX, LINUX, Macintosh (macOS) are some of the examples of
the operating systems. The typical services that an operating system provides include:
a task scheduler, memory manager, disk manager, network manager, Other I/O services
and security manager. This section provides a case study of LINUX operating system.
This unit provides basic structure ofthe Linux, its process management; file management
and memory management techniques.
2.2 OBJECTIVES
After the completion of this unit, you will be able to:
Understand the basic functions of Linux Operating System
Identify the characteristics of the Linux Operating System
Know the evolution of Linux operating system
Understand the process management of Linux and compare with other OS
Understand the memory management approaches in Linux
Understand the File management in Linux
Understand the security features of Linux
Linux has several distributions. Some popular and dominant LINUX distributions for
Desktops include:
Linux Mint
Ubuntu
OpenSUSE
Mageia
Manjaro
Fedora
Arch Linux
Debian
Kali Linux
Elementary OS
Some of the popular Linux distributions, in the Servers category, include:
Red Hat Enterprise Linux (RHEL)
CentOS
Ubuntu Server
SUSE Enterprise Linux
Applications
Shell
Kernel
Hardware
2 FUN
2.6 NDAMEN
NTAL AR
RCHITEC
CTURE OF
O LINU
UX
The
T followingg is the fundam
mental architecture of Linuxx given in Figg 2.
Architecture
A of
o kernel is divvided into maain two parts:
1. Userr Space
2. Kernnel Space
28
2.6.1 User Space Case Study – LINUX
All user programs and applications are executed in user space. User Space cannot
directly access the memory and hardware. It accesses the hardware through kernel
space. Processes or programs which are running in user space only access some part
of memory by systemcall. Due to full protection, crashes in user mode are recoverable.
GNU C library provides the mechanism switching user space application to kernel
space.
Figu
ure 3: Memoryy Management in Linux
2..9 LINU
UX FILE SYSTEM
S M
A file systemis a logical colleectionof files on a partitionn or disk.Aparrtition is a conntainer
or information and can span an entire hard
fo h drive iff desired. Filee system hierrarchy
staandard (FHSS) describes directory
d stru
ucture and itss content in Unix
U and Uniix like
op
perating systeem. It explainns where files and directoriies should be located and w what it
sh
hould containn. Linux partiially follows FHS due to iits own policy to which w we may
no
otice some diffferences in thhe directory trree structure.
Th
he Root Direectory
Alll the directoriies in the Linuux systemcom
me under the rooot directoryw
which is repreesented
byy a forward slash
s (/).
Eaach file is cattegorized baased on the tyype of the filee and is storeed into a partticular
directory. Thesse types of dirrectories and relevant
r file tyypes are listed below in tabble 2.
Ta
able 2: Direcctory Type and
a Types off the Files Sttored
Directory
D typ
pe Typees of files stoored
Binary
B directo
ories Contaains binary or compiled
c sourrce code files, eg,/bin, /sbin,, etc.
Configuration
C Contaains configuraation files of tthe system, eg
g, /etc, /boot.
directories
d
Data
D directoriies Storees data files, eg,
e /home, /rooot, etc.
Memory
M Storess device files which
w doesn'tt take up actuaal hard disk sppace,
directories
d eg, /ddev, /proc, /syys.
Usr
U (Unix Sysstem Contaains sharable,, read only daata, eg, /usr/biin, /usr/lib, etc.
Resources)
R
var
v (variable Contaains larger sizze data, eg, /vvar/log, /var/ccache, etc.
directory)
d
Non-standard
N Direcctories which h do not com
me under staandard FHS,, eg,
directories
d lost+ffound, /run, etc.
e 33
Case Studies 2.9.1 Linux Binary Directory
Binary files are the files which contain executable files. These files are the output of
compilation of the source code. These executable files can be executed on the computer.
Binary directory contains following directories:
/bin
/sbin
/lib
/opt
/bin: The ‘/bin’ directory contains user binaries, executable files, Linux commands
that are used in single user mode, and common commands that are used by all
the users, like cat, cp, cd, ls, etc.
/sbin: The‘/sbin’directoryalso contains executablefiles, butunlike ‘/bin’itonly contains
system binaries which require root privilege to perform certain tasks and are
helpful for system maintenance purpose. e.g. fsck, root, init, ifconfig, etc.
/lib : The ‘/lib’ directory contains shared libraries which are often used by the ‘/bin’
and ‘/sbin’ directories. It also contains kernel module.
/opt: The term ‘opt’ is short for optional. Its main purpose is to store optional
application software packages. Add-on applications from individual vendors
should be installed in ‘/opt’. And so in some systems ‘/opt’ is empty as they
may not have any add-on application.
34 /home
/root Case Study – LINUX
/srv
/media
/mnt
/tmp
/home: The ‘/home’directory stores users personnel files. After the ‘/home’there is a
directory which is generally named at the user’s name like we have ‘/home/
sssit’. Inside this directory we have our sub-directories like Desktop,
Downloads, Documents, pictures, etc.
/root: The ‘/root’directory is the home directory of the root user. The ‘/root’directory
is different from (/) root.
/srv: The term ‘srv’ is short for service. The ‘/srv’ directory contains server specific
data for services provided by the system like www, cvs, rysync, ftp, etc.
/media: The ‘/media’ directory acts as a mount point for removable media devices
such as CD-Rom, floppy, USB devices, etc.This is newly introduced directory
and hence a system can run without this directory also.
/mnt : The term ‘mnt’ stands for mount. The ‘/mnt’ directory should be empty and
sysadmins can only mount temporary filesystems.
/tmp : The term ‘tmp’stands for temporary. Data stored in ‘/tmp’is temporary and
may use either disk space or RAM. When system is rebooted, files under this
directory is automatically deleted. So it is advisable that never use ‘/tmp’ to
store important data.
/var/lib
/var/log : The ‘/var/log’ directory contains all log files.
/var/cache: The ‘/var/cache’ directory stores application cache data. Cache data are
locally generated by I/O or calculation. Cache must be able to regenerate
or restore the data. These files can be deleted without any loss of data.
/var/spool: The ‘/var/spool’ directory is used to spool the files waitingto be processed.
For example, printing queues and mail queues.
/var/lib: The ‘/var/lib’ directory stores the files that contains state information like
databases. File’s data modifies as their respective programs run.
2.10.6 OS Management
Majority of Linux distributions incorporate software management facilities based
on package files and sets of specially prepared Web sites, known
as repositories or channels. Package management utilities construct or update working
copies of software fromthese packages, and execute any other setup tasks that packages
require. Repositories enable the management tools to automatically provide the correct
version of each software product, by downloading the required packages directly
from the relevant repository. Most systems also use checksums and digital signature
tests to ensure that packages areauthentic and correct. Inaddition, package management
tools can identify outdated versions of software by checking the software installed on
a system against the packages in the repositories. This means that you can ensure that
all of the supported software on your system does not suffer from known security
vulnerability, simply by running the update routine.
Check Your Progress 1
1) Mention the important features of LINUX Operating System.
........................................................................................................................
........................................................................................................................
........................................................................................................................
........................................................................................................................
2) Describe the architecture of LINUX.
........................................................................................................................
........................................................................................................................
........................................................................................................................
42 ........................................................................................................................
Case Study – LINUX
2.12 SUMMARY
In this unit, we have discussed issues broadly related to features of LINUX OS,
Architecture and components of LINUX, process management, memory
management and file system in LINUX operating system. In this unit, we also discussed
several theoretical concepts of LINUX system in detail, often useful in your lab for
practice.
i. Linux operating system can work on different types of hardware devices and
Linux kernel supports the installation of any kind of hardware platform.
ii. Linux is an Open Source software i.e., Linux Source code is freely
available. Linux also allow us to upgrade the source code. Many collaborative
groups are working to upgrade and develop their own versions.
iii. Multiuser: Linux operatingsystemis a multiuser system, which means, multiple
users can access the system resources such as RAM, Memory or Application
programs at the same time.
iv. Multiprogramming: Linux operating systemis a multiprogramming system,
which means multiple applications can run at the same time.
vi. Shell: Linux operating system offers a special interpreter program that can
be used to execute commands of the OS. It can be used to do several types
of operations like call application programs, and so on.
vii. Security: Linux operating system offers user security systems using
authentication features like encryption of data or password protection
or controlled access to particular files.
Shell: The shell layer is in between application layer and the kernel. Shell will take
the input from the user applications and sends to the kernel in the form of
instructions and takes output from the kernel and forwards it as a result to the user
application.
Applications: These are the utility programs for the users that run on shell. These
applications like text editor, web browsers, spread sheet applications, etc.
43
Case Studies
2.14 FURTHER READINGS
1. Richard Pertersen, Linux: The Complete Reference, Sixth Edition, McGraw Hill,
2017.
2. MachteltGarrels, Introduction to Linux: A Hands-On Guide, UNIX Academy
Publicaions, 2007.
3. Jason Cannon, Linux for Beginners:An Introduction to the Linux Operating System
and Command Line, Kindle Edition, 2013.
4. Linux System Programming, Robert Love, O’Reilly, 2014.
5. K. Srirengan, Understanding UNIX, PHI, 2002.
44
Case Study – LINUX
UNIT 3 CASE STUDY - ANDROID
Structure
3.0 Introduction
3.1 Objectives
3.2 Salient Features of Android
3.3 Evolution of Android
3.4. Layered Architecture of Android OS
3.5. Processes and Threads Management in Android
3.6 Memory Management in Android
3.7 File Management in Android
3.8 Security Features in Android
3.9 Summary
3.10 Solutions/Answers
3.11 Further Readings
3.0 INTRODUCTION
Across the globe, in more than 190 countries, hundreds of millions of mobile devices
are powered by Android operating system. It has strong user base and conquered
around 75% of the global market share by the end of 2020. Google sponsored the
project at initial stages and in the year 2005, it acquired the whole company. In
September 2008, the first Android-powered device was launched in the market. It’s
popular because it has long list of features, user-friendly, has huge community
support, provides a greater extent of customization, and a large number of companies
build Android-compatible smart phones. At first, the purpose of Android was thought
of as a mobile operating system. However, with the advancement of code libraries
and its popularity among developers of the divergent domain, Android becomes
an absolute set of software for all devices like tablets, wearables, set-top boxes,
smart TVs, notebooks, etc. Android is an open-source operating system based on
modified version of Linux kernel with a Java programming interface for mobile
devices such as Smartphone (Touch Screen Devices who supports Android OS) as
well for Tablets too.
This unit provides a case study onAndroid Operating System. It provides basic structure,
features, process, file and memory management techniques it follows.
3.1 OBJECTIVES
After completing this unit, you will be able to:
Understand the various features of the Android system
Know the evolution of the Android OS 45
Case Studies Describe the architecture of the ANDROID OS.
Know the Process and Memory management approaches
Understand the File management inAndroid
Identify the security features inAndroid
Figu
ure 1:Architeccture of Androiid OS (Source: developer.and
droid.com)
3.4.1
3 Linu
ux Kernel
Linux
L is the bottom
b layerr. The bottom m layer offerss a level of abstraction bbetween
hardware
h andd it contains alll the essentiaals required for
fo hardware drivers
d like camera,
c
keypad,
k displaay etc. Also, tthe kernel hanndles all the thhings that Linnux is really good
g at
suuch as netwoorking and a vast array of o device drivvers, which taake the pain out of
in
nterfacing to peripheral
p harrdware.
3.4.2
3 Librraries
A rich set of libraries
l are present
p on toop of Linux kernel.
k Alonng with open--source
Library
L Web browser
b enginne WebKit, a collection
c of popular librarries like libc, SQLite
database
d which h is a useful reepository for storage
s and shharing ofappllication data, libraries
l
to
o play and reccord audio annd video, SSL L libraries ressponsible for Internet
I securrity etc.
Java
J based libbraries are ussed for the puurpose of development of o Android OS. O The
application
a fraamework libraaries in additio on to those thaat facilitate useer interface buuilding,
graphics
g draw
wing and databbase access.
A summary off some key coore Android libraries
l avaiilable to the Android
A develloper is
as
a follows:
android.app Provvides access too the applicatiion model andd is the cornerrstone
of alllAndroid appplications.
android.conttent Faciilitates contennt access, pubblishing and messaging
m betw
ween
appllications and application coomponents.
48
Case Study – Android
android.database Used to access data published by content providers and
includes SQLite database management classes.
android.opengl AJava interface to the OpenGLES 3D graphics renderingAPI.
android.os Provides applications with access to standard operating system
services including messages, system services and inter-process
communication
android.text Used to render and manipulate text on a device display.
android.view The fundamental building blocks of application user interfaces.
android.widget A rich collectionof pre-built user interface components such as
buttons, labels, list views, layout managers, radio buttons etc.
android.webkit A set of classes intended to allow web-browsing capabilities
to be built into applications.
A visible process is considered extremely important and will not be killed unless doing
so is required to keep all foreground processes running.
(iii) Service process
A process that is running a service that has been started with the startService() method
and does not fall into either of the two higher categories. Although service processes
are not directly tied to anything the user sees, they are generally doing things that the
user cares about such as playing music in the background or downloading data on the
network, so the system keeps them running unless there’s not enough memory to retain
them along with all foreground and visible processes.
(iv) Background process
A process holding an activity that’s not currently visible to the user (the
activity’s onStop() method has been called). These processes have no direct impact
on the user experience, and the system can kill them at any time to reclaim memory for
a foreground, visible, or service process. Usually there are many background processes
running, so they are kept in an LRU (least recently used) list to ensure that the process
with the activity that was most recently seen by the user is the last to be killed. If an
activity implements its lifecycle methods correctly, and saves its current state, killing its
process will not have a visible effect on the user experience, because when the user
navigates back to the activity, the activity restores all of its visible state.
(v) Empty process
A process that doesn’t hold any active application components is called empty process.
The only reason to keep this kind of process alive is for caching purposes, to improve
startup time the next time a component needs to run in it. The systemoften kills these
processes in order to balance overall system resources between process caches and
the underlying kernel caches.
Android ranks a process at the highest level it can, based upon the importance of the
components currently active in the process.
3.5.2 Threads
When an application is launched, the system creates a thread of execution for the
application, called “main”. This thread is very important because it is in charge of
dispatching events to the appropriate user interface widgets, including drawing events.
It is also the thread in which your application interacts with components from the
Android UI toolkit. This main thread is also sometimes called the UI thread.
The system does not create a separate thread for each instance of a component. All
components that run in the same process are instantiated in the UI thread, and system
calls to each component are dispatched from that thread. Consequently, methods that
respond to systemcallbacks (such as onKeyDown() to report user actions or a lifecycle
callback method) always run in the UI thread of the process.
For instance, when the user touches a button on the screen, your app’s UI thread
dispatches the touch event to the widget, which in turn sets its pressed state and posts
an invalidate request to the event queue. The UI thread dequeues the request and
notifies the widget that it should redraw itself. 51
Case Studies When your app performs intensive work in response to user interaction, this single
thread model can yield poor performance unless you implement your application
properly. Specifically, if everything is happening in the UI thread, performing long
operations such as network access or database queries will block the whole UI. When
the thread is blocked, no events can be dispatched, including drawing events. From
the user’s perspective, the application appears to hang. Even worse, if the UI thread is
blocked for more than a few seconds (about 5 seconds currently) the user is presented
with the infamous “application not responding”” (ANR) dialog. The user might then
decide to quit your application and uninstall it if they are unhappy. Additionally, the
Android UI toolkit is not thread-safe.
Interprocess Communication
Android offers a mechanism for Interprocess Communication (IPC) using remote
procedure calls (RPCs), in which a method is called by an activity or other application
component, but executed remotely (in another process), with any result returned back
to the caller. This entails decomposing a method call and its data to a level the operating
system can understand, transmitting it from the local process and address space to the
remote process and address space, then reassembling and reenacting the call there.
Return values are then transmitted in the opposite direction. Android provides all the
code to performthese IPC transactions, so you can focus on defining and implementing
the RPC programming interface. To perform IPC, your application must bind to a
service, using bindService().
In the next section we will study about the Memory Management inAndroid OS.
RA
AM
CPU
Storage
GPU zR
RAM
3..6.3 Mem
mory Alloccation Among Proceesses
Thhe Android pllatform runs on o the premisse that free meemory is wastted memory. It tries
to use all of thee available meemory at all times.
t For exaample, the syystem keeps aapps in
memory
m after they’ve
t beenn closed so thhe user can quuickly switchh back to them
m. For
thiis reason,Anddroid devices often
o runwith hvery little freeememory. Memory
M managgement
is vital to propeerly allocate memory
m amonng important system proceesses and manny user
appplications.
53
Case Studies 3.6.4 Paging
RAM is broken up into pages. Typically each page is 4KB of memory. Pages are
considered either free or used. Free pages are unused RAM. Used pages are RAM
that the system is actively using, and are grouped into the following categories:
Cached: Memory backed by a file on storage (for example, code or memory-
mapped files). There are two types of cached memory:
Private: Owned by one process and not shared.
Clean: Unmodified copy of a file on storage, can be deleted by kswapd to
increase free memory.
Dirty: Modified copy of the file on storage; can be moved to, or compressed
in, zRAM by kswapd to increase free memory or allows changes to be
written back to the file in storage to increase free memory by kswapd, or
explicitly using msync() or munmap()or Can be
moved/compressed in zRAM by kswapd to increase free memory
Shared: Used by multiple processes.
Anonymous: Memory not backed bya file on storage (for example, allocated
by mmap() with the MAP_ANONYMOUS flag set).
App signing
App-defined and user-granted permissions
3.8.6 Cryptography
Android provides a set of cryptographic APIs for use by applications. These include
implementations of standard and commonly used cryptographic primitives such asAES,
RSA, DSA, and SHA. Additionally, APIs are provided for higher level protocols such
as SSL and HTTPS.
Check Your Progress 1
1) Mention and explain briefly the main building blocks ofAndroid platform.
........................................................................................................................
........................................................................................................................
........................................................................................................................
........................................................................................................................
3.9 SUMMARY
Android is a powerful open-source operating system which provides a lot of great
features. Its open-source and we can customize the OS based on our requirements. It
supports connectivity for GSM, CDMA, WIFI, NFC, Bluetooth, etc. for telephony
or data transfer. It will allow us to make or receive a calls / SMS messages and we can
send or retrieve data across mobile networks. By using WIFI technology we can pair
with other devices using apps. Android has multiple APIs to support location-based
services such as GPS. We can perform all data storage related activities by using
60 lightweight database SQLite. It has a wide range of media supports like AVI, MKV,
FLV, MPEG4, etc. to play or record a variety of audio/video and having a different Case Study – Android
image format like JPEG, PNG, GIF, BMP, MP3, etc. . It has extensive support for
multimedia hardware control to perform playback or recording using camera and
microphone. It has an integrated open-source WebKit layout based web browser to
support HTML5, CSS3. It supports a multi-tasking, we can move from one task
windowto another and multiple applications can run simultaneously. It willgive a chance
to reuse the application components and the replacement of native applications. We
can access the hardware components like Camera, GPS, and Accelerometer. It has
support for 2D/3D Graphics.
In thisunit, we have discussedfeaturesofAndroid OS,Architecture, process management,
memory management, file system and security aspects inAndroid operating system.
62
Case Study – Android
UNIT 4 CASE STUDY - iOS
Structure
4.0 Introduction
4.1 Objectives
4.2 Features of iOS
4.3 Evolution of iOS
4.4 Architecture of iOS
4.5 iOS Kernel Architecture
4.6 Processes and Threads Management
4.6.1 Threading Packages
4.6.2 Threads Alternatives
4.7 Memory Management
4.7.1 Application Memory Management
4.7.2 Virtual Memory Management
4.7.3 Page List in Kernel
4.7.4 Page Fault
4.8 File System in iOS
4.8.1 iOS Directories
4.8.2 iCloud Container
4.8.3 Identification of File Type
4.8.4 Security of File System
4.9 Summary
4.10 Solutions / Answers
4.11 Further Readings
4.0 INTRODUCTION
iPhone operating system (iOS) is a mobile operating system developed by Apple Inc.
used for apple handheld devices. It is used in devices like- iPhone, iPad and iPod. It is
the second most widely used mobile operating system. It supports features like direct
manipulation and can respond to various types of user gestures. It is proprietary and
closed source and derived from macOS. Software development kit (SDK) is provided
to create applications. It includes interfaces for developing, running and testing
applications. Apps can be written using system frameworks and Objective-C
programming language.
Initial three versions were introduced with the name iPhone OS. From fourth version,
they renamed it to iOS. With each new version, new features and apps were added.
iOS 13 is latest version which was released in 2019. Its major feature is dark mode
and new Map application with street view capability. It also enhanced its previous
apps and features like-Siri, Heath map and others. iOS 14 is about to release in
2020. 63
Case Studies
4.1 OBJECTIVES
After going through this unit, you should be able to:
Understand the basic functions of iOS Operating System
Know the history of iOS operating system
Understand the process management in iOS and can compare with other OS
Understand the memory management approaches in iOS
Understand the File management in iOS
Understand the security features in iOS
4..4.1 Coree OS
It is the lowest layer
l in the iO
OS architecturre hence respoonsible for prroviding basicc low
levvel features. The
T framewoorks present inn this layer aree:
Securiity services frramework
Autheentication fraamework
Bluetoooth framewo
ork
Externnal accessory
y framework
Accelerate framew
work
Fig
F 2: XNU keernel Architectture
(Source: deveeloper.apple.coom)
4.7 MEMORYMANAGEMENT
For effective and efficient utilization of memory, memory management is required by
the iOS. Resource needs to be free up when they are not required. In iOS memory
used by applications is managed by maintaining the life cycle of objects and freeing
them when not required. To identify that an object is no more required; its object graph
is created. The group of objects that are related to each other forms object graph. In
this, objects can be related by the direct reference or indirect reference.
Fig
g3: Difference between
b Autom matic and Man nual Reference Counting
(Source: devveloper.apple.ccom)
Memory
M management usinng Reference counting is based b on Ownnership of object. An
object
o can be owned by one or many owners.o Thee object contiinues to existt till the
tiime it has atleeast one owneer. The objectt is destroyed automaticallyy at runtime iff has no
owner.
o Hencee, ownership is the ability of causing obbject to be destroyed.
a.
a Referencce Count Model
Memory
M is maanaged by maaintaining lifefe cycle of an object. Whenn the objects are not
needed,
n it shoould be de-allocated. Whhen an object is created or o copied, itss retain
count
c is set to 1.
1 This retainn count can inccreasewith tim
me if ownership
p interest is exxpressed
by
b other objeccts. The retainn count can alsoa be decrem mented if objjects relinquish their
in
nterest of owwnership. The object will be maintainedd in memory tiill it’s retain countc is
not
n zero. The object will bee deallocatedd once it’s retaain count reaches zero.
Fig
F 4: Reference Counting Model
M (Source: developer.applle.com)
b.
b Automattic Reference Counting
Automatic
A refference countting is a comppiler provideed feature thatt manages meemory
automatically
a of
o Object-C oobjects. Auto omatic referennce counting is
i an ownersship
72 syystem which provides connvention for management
m and transferr of ownershiip. It
the object’s lifetime requirements and user need not to remember about retain and Case Study – iOS
releases. It allows object to be pointed by two types of references- strong and week.
An object which is strongly referenced will be preserved and never deleted. The objects
having back reference is called weak reference and can be de-allocated (destroyed).
When no strong reference to objects is left, the object automatically becomes nil.
Hence weak reference does not increase life time of objects. This model also imposes
some restricts to prevent memory faults or issues.
4.8
4 FILE
E MANAG
GEMEN
NT SYSTE
EM
Storage
S of datta, files, applications, opeerating system
m files is mannaged by file system.
s
The
T default fiile system useed in iOS is APFS
A for verrsions after iO
OS 10.3. Befo
fore this
HFS+
H was deffault file systtem. In iOS user cannot acccess file systtem directly but
b they
can
c access it using
u applicatiions.
4.8.1
4 iOS Directoriies
Applications
A c interact with
can w file systeem only its saandbox directtory. When thhe apps
are
a installed, various
v contaainer directorries are creatted in its sanddbox directoryy. Here
every
e containner is created for a specificc role. There aare two main n containers ––bundle
container
c and data containeer. Data contaainer is furtheer divided into o subdirectoriies used
too organize appp’s data. Inn addition to theses contaainers, apps can c also requuest for
additional
a conntainers exampple iCloud coontainer.
F
Fig5: Sandbox directory of iOOSApp
74 (Source: devveloper.apple.com)
Files outside these containers are generally restricted for use by applications. Use of Case Study – iOS
public system interfaces like contacts and music is exception to this rule.System
framework in this case uses helper apps to perform file operations by modifying or
reading from appropriate data storage locations.
Some of the commonly used directories in iOS sandbox are –
(i) Appname.app
This directory is created during app’s installation. It contains the app’s
executable data and resources. User should not write to this directory because
app may not launch due to change in signature. However, user can get read
only access to app’s bundle data.
(ii) Documents/
Data generated by user is stored in this directory. Files present in this directory
can be accessed by user using file sharing. This directory is also backed up by
iCloud and iTune.
(iii) Documents/Inbox
It is a subdirectory within Documents which is required by apps to open files
asked by outside entities. Apps can read and delete data from this directory
but cannot modify and create new files. Generally email attachments related
to apps are placed in this directory by mail program. This directory is also
backed up by iCloud and iTune.
(iv) Library/
This subdirectory is used to store data which is not required to be exposed to
user. It contains applications support, preferences and cache subdirectories
for iOS apps. Custom subdirectories can also be created by user but should
not be used for user data.This directory is placed in data bundle. Except
cache all the contents of this directory are also backed up.
(v) tmp/
This directory is used to store temporary file i.e. files that are not needed to
persist. These file must be deleted by the apps when they are not needed.
When apps arenot running, systemmaydelete thesesfiles. Datain this directory
is not backed up.
For proper organization of files, additional subdirectories can be created within
Documents, tmp and Library by iOS apps.
Check Your Progress 1
1) Describe the important features of iOS 14.4 version.
........................................................................................................................
........................................................................................................................
........................................................................................................................
........................................................................................................................
4.9 SUMMARY
In this unit we had studied iOS operating system. iOS is a mobile operating system
developed byApple Inc for iPhone.Adescription of howprocess management, memory
management, file management, security in iOS is discussed in this unit. Along with
various functions of the iOS operating system, its evolution, architecture, and other
features were described.
In this course we had studied Operating Systems in general and 4 case studies.
78