Summer - 19 Examination Subject Name: Operating System Model Answer Subject Code
Summer - 19 Examination Subject Name: Operating System Model Answer Subject Code
Summer - 19 Examination Subject Name: Operating System Model Answer Subject Code
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER – 19 EXAMINATION
Advantage:
This approach makes it easy to build, maintain and enhance the
operating system.
Locating an error is easy as system can start debugging from 0th layer
and proceed further covering entire system if required.
Disadvantage:
Overall performance speed is slow as requests pass through multiple
layers of software before they reach the hardware.
OR
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Example:
Consider, an e-mail program, a web browser and a word processor is loaded
into RAM simultaneously; the 64 MB space is not enough to store all these
programs. Without a virtual memory, a message “You cannot load any more
applications. Please close an application to load a new one.” would be
displayed. By using a virtual memory, a computer can look for empty areas of
RAM which is not being used currently and copies them on to the hard disk
device. Thus RAM is freed to load new applications. Actually it is done
automatically, the user do not even know that it is happening, and the user
feels like RAM has unlimited space even though the RAM capacity is 32 MB. It
is a process of increasing computer’s RAM by using a section of the hard disk
storage as an extension of RAM.
(iv) Explain Real Time Operating System. Explain its types 4
Ans: Real time system has well defined fixed time constraints. Processing should be Explanation
done within the Defined constraints. A primary objective of real-time systems 2M
is to provide quick event response time and thus meet the scheduling Types:
deadlines. User convenience and resource utilization are of secondary concern 1M each
to real-time system designers. In Real time systems, processor is allocated to
the highest priority process among those that are ready to execute. Higher
priority processes preempt execution of the lower priority processes. This form
is called as ‘priority–based preemptive scheduling’.
The primary functions of the real time operating system are to:
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
2. Soft Real Time: Soft real time means that only the precedence and sequence
for the task operations are defined, interrupt latencies and context switching
latencies are small. There can be few deviations between expected latencies of
the tasks and observed time constraints and a few deadline misses are
accepted.
Example: Mobile phone, Digital Cameras and orchestra playing robots.
(ii) Explain any six services of Operating System. Draw diagram of services of OS 6
Ans: 1. User Interface: All operating systems have a user interface that allows Services: 4M
users to communicate with the system. Diagram:
Three types of user interfaces are available: 2M
a. Command line interface (CLI)
b. Batch interface
c. Graphical user interface (GUI)
4. File system manipulation: - Programs may need to read and write data from
and to the files and directories. Operating system manages the secondary
storage. User gives a command for reading or writing to a file. Operating system
makes it easier for user programs to accomplish their task such as opening a
file, saving a file and deleting a file from the storage disk. It also provides
services for file permission management to allow or deny access to files or
directories based on file ownership.
For each type of error, the operating system should take the appropriate action
to ensure correct and consistent computing. Debugging facilities can greatly
enhance the user’s and programmer’s abilities to use the system efficiently.
Ans: Explanation:
3M
Diagram:
1M
The Unix file system is a methodology for logically organizing and storing large
quantities of data such that the system is easy to manage. A file can be
informally defined as a collection of related data, which can be logically viewed
as a stream of bytes (i.e. characters). A file is the smallest unit of storage in the
Unix file system.
The Unix file system has a hierarchical (or tree-like) structure with its highest
level directory called root (denoted by /, pronounced slash). Immediately
below the root level directory are several subdirectories, most of which contain
system files. Below this can exist system files, application files, and/or user data
files. Similar to the concept of the process parent-child relationship, all files on
a UNIX system are related to one another. That is, files also have a parent-child
existence. Thus, all files (except one) share a common parental link, the top-
most file (i.e. /) being the exception.
Below is a diagram of a "typical" Unix file system. The top-most directory is /
(slash), with the directories directly beneath being system directories.
b) Describe Multiprocessor Operating System with its two advantages 4
Ans: Multiprocessor systems are also known as parallel systems or tightly coupled Description:
systems. These systems have two or more processors in close communication 2M
and they share computer resources such as bus, clock, memory and peripheral Two
devices. Advantages:
The whole task of multiprocessing is managed by the operating system, which 2M
allocates different tasks to be performed by the various processors in the
system. Applications designed for the use in multiprocessing are said to be
threaded, which means that they are broken into smaller routines that can be
run independently. This allows the operating system to let these threads run
on more than one processor simultaneously, which is multiprocessing that
results in improved performance. Generally, the parallel processing is used in
the fields like artificial intelligence and expert system, image processing,
weather forecasting etc.
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Advantages:
Increased throughput: Increase in number of processors requires less
time for more work. Number of processes completing their task for a
particular duration is more.
Economy of scale: Cost is less than multiple single processor systems.
If several programs operate on the same set of data, then it is cheaper
to store those data on one disk and to have all the processors share
them.
Increase reliability: Functions can be distributed properly among
several processors and then the failure of one processor will not halt
the system.
(c) List different directory structure and explain any one in detail 4
Ans: List of directory structures: List: 1M
Single level directory structure Explain One
Two level directory structure Structure:
2M,
Single level directory structure: It is the simplest form of directory structure, Diagram: 1M
having one directory containing all the files, and each file must have a unique
name. Software design is simple. The advantages of this scheme are its
simplicity and the ability to locate files quickly.
Since all files are in the same directory, they must have unique names. If there
are two users who call their data file "test", then the unique-name rule is
violated. Even with a single-user, as the number of files increases, it becomes
difficult to remember the names of all the files in order to create files with
unique name.
Two level directory structure: In this structure, each user has its own user file
directory (UFD). The UFD lists only files of a single user. System contains a
master file directory (MFD) which is indexed by user name or account number.
Each entry in MFD points to the UFD for that user.
When a user refers to a particular file, only his own UFD is searched. Different
users can have files with the same name, as long as all the file names within
each UFD are unique. When we create a file for a user, operating system
searches only that user’s UFD same name file already present in the directory.
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
For deleting a file again operating system checks the file name in the user’s UFD
only.
6. Login: The login process prompts the user for a password. It validates the
login name and the password against the entry in the /etc/passwd file and the
/etc/shadow file. The users shell specified in the Home directory.
7. Shell: The shell prints the Unix prompt and executes user commands when
user logs out, sh is taken over by login to allow the next user to log in.
(e) Explain Process Control Block with suitable Diagram 4
Ans: Each process is represented as a process control block (PCB) in the operating Explanation:
system. It contains information associated with specific process. 2M
Process State: It indicates current states of a process. Process state can be new, Diagram:
ready, running, waiting and terminated. 2M
Process number: Each process is identified by its process number, called
process identification number (PID).
Program Counter: It indicates the address of the next instruction to be
executed for the process.
CPU Registers: The registers vary in number and type depending on the
computer architecture. Register includes accumulators, index registers, stack
pointers and general purpose registers plus any condition code information.
Memory Management Information: It includes information such as value of
base and limit registers, page tables, segment tables, depending on the
memory system used by operating system.
Accounting Information: This information includes the amount of CPU used,
time limits, account holders, job or process number and so on. It also includes
information about listed I/O devices allocated to the process such as list of
open files.
(f) Explain Shortest Remaining Time Next (SRTN) scheduling algorithm with 4
example
Ans: SRTN: Shortest Remaining Time Next Explanation:
A Shortest remaining Time Next scheduling algorithm is also referred as 2M
preemptive SJF scheduling algorithm. When a new process arrives at ready Example: 2M
queue while one process is still executing then SRTN algorithm is performed to
decide which process will execute next. This algorithm compare CPU burst time
of newly arrived process with remaining (left) CPU burst time of currently
executing process. If CPU burst time of new process is less than remaining time
of current process then SRTN algorithm preempts current process execution
and starts executing new process.
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Example: Consider four processes with arrival time and burst time mentioned
below in table.
Gantt chart:
As P1 is the only process in ready queue at time 0,P1 will start execution
first.
At time 1, process P2 arrives. The Burst time of P2 i.e 4 ms is less than
remaining burst time of process P1 i.e.7 ms, so process P1 is preempted
and process P2 starts executing.
At time 2, process P3 arrives. The Burst time of P3 i.e. 9 ms is greater
than remaining burst time of process P2 i.e. 3 ms, so Process P2
continues its execution.
At time 3, process P4 arrives. The Burst time of P4 i.e. 5 ms is greater
than remaining burst time of process P2 i.e. 2 ms, so Process P2
continues its execution.
When P2 process completes its execution, all remaining processes
execute with shortest job first algorithm.
Waiting time of processes:
P1:9 ms
P2:0 ms
P3:15 ms
P4: 2 ms
Average waiting time= (9+0+15+2)/4=26/4=6.5 ms
4. The caller needs to know nothing about how the system call is
implemented. Just needs to obey API and understand what OS will do
as a result call.
5. Most details of operating system interface hidden from programmers
by API. It is managed by run-time support library.
Open ( ) system call for most file systems, a program initializes access to a file
in a file system using the open system call. This allocates resources associated
to the file (the file descriptor), and returns a handle that the process will use to
refer to that file.
b) Explain different file attributes 4
Ans: File attributes: Explanation
Name: The symbolic file name is the only information kept in human of any 4 file
readable form. attributes: 1
Identifier: File system gives a unique tag or number that identifies file mark each
within file system and which is used to refer files internally.
Type: This information is needed for those systems that support
different types.
Location: This information is a pointer to a device and to the location
of the file on that device.
Size: The current size of the file (in bytes, words or blocks) and possibly
the maximum allowed size are included in this attribute.
Protection: Access control information determines that who can do
reading, writing, executing and so on.
Time, Date and User Identification: This information may be kept for
creation, Last modification and last use. These data can be useful for
protection, security and usage monitoring.
c) Explain any four benefits of using threads 4
Ans: The benefits of using threads: Any four
Responsiveness: Multithreading an interactive application may allow a Benefits: 1M
program to continue running even if part of it is blocked or is each
performing a lengthy operation, thereby increasing responsiveness to
the user. For instance, a multithreaded web browser could still allow
user interaction in one thread while an image was being loaded in
another thread.
Resource sharing: By default, threads share the memory and the
resources of the process to which they belong. The benefit of sharing
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Less Secure (If one service fails, More Secure (Even if one service
entire system crashes) crashes, others can function
properly because of separation)
(ii) Explain critical section problem with example 4
Ans: Each process contains two sections. One is critical section where a process may Explanation:
need to access common variable or objects and other is remaining section 2M
containing instructions for processing of sharable objects or local objects of the Example: 2M
process. Each process must request for permission to enter inside its critical
section. The section of code implementing this request is the entry section. In
entry section if a process gets permission to enter into the critical section then
it works with common data. At this time all other processes are in waiting state
for the same data. The critical section is followed by an exit section. Once the
process completes its task, it releases the common data in exit section. Then
the remaining code placed in the remainder section is executed by the process.
Two processes cannot execute their critical sections at the same time. The
critical section problem is to design a protocol that the processes can use to
cooperate i.e. allowing entry to only one process at a time inside the critical
section. Before entering into the critical section each process must request for
permission to entry inside critical section.
(iii) Explain different activities of I/O system management components of OS 4
Ans: I/O System: Input / Output device management provides an environment for Description
the better interaction between system and the I / O devices such as printers, of four
scanners, tape drives etc. To interact with I/O devices in an effective manner, activities of
the operating system uses some special programs known as device driver. The I/O system: 1
device drivers take the data that operating system has defined as a file and mark each
then translate them into streams of bits or a series of laser. A device driver is a
specific type of computer software that is developed to allow interaction with
hardware devices. Typically this continues an interface for communicating with
the I/O device, through the specific computer bus or communication
subsystem that the hardware is connected with. The device driver is a
specialized hardware dependent computer program that enables another
program, typically an operating system to interact transparently with a
hardware device, and usually provides the required interrupt handling
necessary for the time dependent hardware interfacing.
Activities:
Providing interfaces to other system components.
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Managing devices
Transferring data
Detecting I/O completion
(iv) Explain user thread and kernel threads 4
Ans: User-Level Threads: Explanation
A user-level thread is a thread within a process which the OS does not of User
know about. Thread: 2
In a user-level thread approach the cost of a context switch between marks,
threads less since the operating system itself does not need to be Explanation
involved–no extra system calls are required. of Kernel
A user-level thread is represented by a program counter; registers, Thread: 2
stack, and small thread control block (TCB). marks
Programmers typically use a thread library to simplify management of
threads within a process.
Creating a new thread, switching between threads, and synchronizing
threads are done via function calls into the library. This provides an
interface for creating and stopping threads, as well as control over
how they are scheduled.
Kernel Threads:
In systems that use kernel-level threads, the operating system itself is
aware of each individual thread.
Kernel threads are supported and managed directly by the operating
system.
A context switch between kernel threads belonging to the same
process requires only the registers, program counter, and stack to be
changed; the overall memory management information does not
need to be switched since both of the threads share the same address
space. Thus context switching between two kernel threads is slightly
faster than switching between two processes.
Kernel threads can be expensive because system calls are required to
switch between threads. Also, since the operating system is
responsible for scheduling the threads, the application does not have
any control over how its threads are managed.
Diagram, 2
mark
Explanation)
Message Passing:
The simplest access method is sequential access. Information in the file is Description
processed in order, one record after the other. This mode of access is by far the of each: 3
beginning current position most common; for example, editors and compilers marks (1
usually access files in this fashion. Reads and writes make up the bulk of the mark
operations on a file. A read operation read next reads the next portion of the Diagram, 2
file and automatically advances a file pointer, which tracks the I/O location. mark
Similarly, the write operation write next appends to the end of the file and Explanation)
advances to the end of the newly written material (the new end of file).
To read a piece of data that is stored at the end of the file, one has to read all
of the data that comes before it-you cannot jump directly to the desired data.
This is similar to the way cassette tape players work. If one wants to listen to
the last song on a cassette tape, he has to either fast-forward over all of the
songs that come before it or listen to them. There is no way to jump directly to
a specific song.
Advantages:-
It is an efficient model as threads are managed by thread library in user
space.
Portable: Because user level threads packages are implemented
entirely with standard Unix and POSIX library calls, they are often quite
portable.
One kernel level thread controls multiple user level threads.
Easy to do with few system dependencies.
Disadvantages:
One block call from kernel level thread blocks all user level threads.
Cannot take advantage of multiprocessing.
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Advantages:
It allows multiple threads to run in parallel on multiprocessors.
More concurrency
Less complication in processing
Disadvantages:
Creating a user thread requires creating the corresponding kernel
thread. Creating kernel thread may affect the performance of an
application.
It reduces performance of the system.
Kernel thread is overhead.
b) Calculate Average locating Time for SJF (Shortest Job First) and Round Robin 8
(RR) algorithm for following table: (Time Slice 4 msec)
Process Burst Time
P1 10
P2 04
P3 09
P4 06
Ans: SJF: Gantt chart:
Gantt Chart: 2 marks
each,
Average
waiting time:
2 marks each
Waiting Time and Turn Around Time Table:
Process Burst Time Waiting Time Turn Around Time
P1 10 19 29
P2 04 0 04
P3 09 10 19
P4 06 4 10
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
RR:
Gantt Chart:
Hardware:
The hardware is Centre of structure that provides the Operating
System with basic services.
The hardware consists of all peripherals like memory (RAM, HDD, FDD
etc) processor, mouse, and other input devices, terminals, printers etc.
The Kernel:
The kernel is the heart of the system - a collection of programs mostly
written in ‘C’ which communicate with the hardware directly.
Kernel is an interface between hardware of the system and shell. It is
loaded into the memory when the system is booted.
User programs that need to communicate with the hardware use the
services of the kernel, which performs the job on the user’s behalf.
It manages the system’s memory, schedules processes, decides their
priorities and performs other tasks.
Shell:
The shell is an interface between the user and the kernel that isolates
the user from knowledge of kernel functions.
The shell accepts the commands keyed by the users and checks for
their syntax and gives out error messages if something goes wrong.
It is a command interpreter of user requests.
Application programs:
The various compilers for languages like c, c++, pascal, fortran and
other application programs written by programmers which are used by
users for their operations falls in this layers.
Only those persons who maintain on “account” with the computer
system can use the UNIX system.
User can directly access application programs through which they can
interact with the system.
c) Explain distributed Operating System with advantages and disadvantages 4
Ans: A distributed system consists of a collection of autonomous 2 Marks:-
computers, connected through a network and distribution Explanation;
middleware, which enables computers to coordinate their activities 1 Mark:-
and to share the resources of the system, so that users perceive the Advantage; 1
system as a single, integrated computing facility. Mark:-
In such system the processors do not share memory or a clock; Disadvantage
instead each processor has its own local memory.
In such systems, if one machine or site fails the remaining sites can
continue operation.
So these types of systems are the reliable systems.
The processors communicate with one another through various
communications lines, such as a high speed buses or telephone lines.
These systems are usually referred to as Loosely Coupled Systems or
Distributed Systems
The structure shown in figure contains a set of individual computer
systems and workstations connected via communication systems.
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Advantages:
With resource sharing facility, a user at one site may be able to use
the resources available at another.
Speedup the exchange of data with one another via electronic mail.
If one site fails in a distributed system, the remaining sites can
potentially continue operating.
Better service to the customers.
Reduction of the load on the host computer.
Reduction of delays in data processing.
Disadvantages:
Security problem due to sharing
Some messages can be lost in the network system
Bandwidth is another problem if there is large data then all network
wires to be replaced which tends to become expensive
Overloading is another problem in distributed operating systems
If there is a database connected on local system and many users
accessing that database through remote or distributed way, then
performance become slow
The databases in network operating is difficult to administrate then
single user system
d) List different file allocation methods. Explain any one in detail 4
Ans: File allocation methods are: 1 Mark-
Contiguous Allocation method Listing;( 2
Linked Allocation method Marks-
Indexed Allocation method Explanation;
1 Mark-
Diagram( any
one
method)))
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Contiguous Allocation
The contiguous allocation method requires each file to occupy a set of
contiguous address on the disk.
Disk addresses define a linear ordering on the disk.
With this ordering, accessing block b+1 after block b normally
requires no head movement.
Contiguous allocation of a file is defined by the disk address and the
length of the first block. If the file is n blocks long, and starts at
location b, then it occupies blocks b, b+1, b+2, …, b+n-1.
The directory entry for each file indicates the address of the starting
block and the length of the area allocated for this file
linked Allocation:
In this method, each file occupies disk blocks scattered anywhere on
the disk.
It is a linked list of allocated blocks.
When space has to be allocated to the file, any free block can be used
from the disk and system makes an entry in directory.
Directory entry for allocated file contains file name, a pointer to the
first allocated block and last allocated block of the file.
The file pointer is initialized to nil value to indicate empty file.
A write to a file, causes search of free block.
After getting free block data is written to the file and that block is linked
to the end of the file.
To read the file, read blocks by following the pointers from block to
block starting with block address specified in the directory entry.
For example, a file of five blocks starting with block 9 and continue with
block 16,then block 1,then block 10 an finally block 25.each allocated
block contains a pointer to the next block.
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Indexed Allocation:
In this method, each file has its own index block.
This index block is an array of disk block addresses.
When a file is created, an index block and other disk blocks according
to the file size are allocated to that file.
Pointer to each allocated block is stored in the index block of that file.
Directory entry contains file name and address of index block.
When any block is allocated to the file, its address is updated in the
index block.
Any free disk block can be allocated to the file. Each ith entry in the
index block points to the ith block of the file. To find and read the ith
block, we use the pointer in the ith index block entry.
When the scheduler switches the CPU from executing one process to
execute another, the context switcher saves the content of all
processor registers for the process being removed from the CPU, in
its process descriptor.
The context of a process is represented in the process control block of
a process.
Context switch time is pure overhead.
Context switching can significantly affect performance as modern
computers have a lot of general and status registers to be saved.
Content switching times are highly dependent on hardware support