Sample Question Solved
Sample Question Solved
Q Questions/ Answer Ma
u rk
e. s
a) Differentiate between Batch Operating System and Time shared Operating
System.
(any two points)
Sr. Batch Operating System Time shared Operating
No System
1 There is an operator which takes Each task is given some time to
similar jobs having same execute, so that all the tasks
requirement and group them into work smoothly
batches.
2 It is very difficult to guess or know Each task gets an equal
the time required by any job to opportunity
complete
b) State any four services of Operating System.
Here is a list of common services offered by an almost all operating systems:
User Interface
Program Execution
File system manipulation
Input / Output Operations
Communication
Resource Allocation
Error Detection
Accounting
Security and protection
ps
Q.
2)
a) Explain dual modes of operations of an Operating system.
There are two modes of operation in the operating system to make sure it
works correctly. These are user mode and kernel mode.
A diagram that illustrates the transition from user mode to kernel mode and
back again is as follows:
User Mode:
The system is in user mode when the operating system is running a user
application such as handling a text editor. The transition from user mode to
kernel mode occurs when the application requests the help of operating
system or an interrupt or a system call occurs.
The mode bit is set to 1 in the user mode. It is changed from 1 to 0 when
switching from user mode to kernel mode.
Kernel Mode
The system starts in kernel mode when it boots and after the operating
system is loaded, it executes applications in user mode. There are some
privileged instructions that can only be executed in kernel mode. These are
interrupt instructions, input output management etc. If the privileged
instructions are executed in user mode, it is illegal and a trap is generated.
The mode bit is set to 0 in the kernel mode. It is changed from 0 to 1 when
switching from kernel mode to user mode.
All the processes that use the shared memory model need to make sure
that they are not writing to the same memory location.
Shared memory model may create problems such as synchronization
and memory protection that need to be addressed.
Q. 12
3 M
a) Define PCB. List information contained in PCB and explain any two 4
M
Each process is represented as a process control block (PCB) in the operating
system. It contains
Information associated with specific process.
In general, a PCB may contain information regarding:
1. Process Number: Each process is identified by its process number, called
process identification
number (PID).
2. Priority: Each process is assigned a certain level of priority that
corresponds to the relative importance of the event that it services.
3. Process State: This information is about the current state of the process. I.e.
whether process is in
new, ready, running, waiting or terminated state.
4. Program Counter: This contains the address of the next instruction to be
executed for this process.
5. CPU Registers: CPU registers vary in number and type, depending upon the
computer architectures. These include index registers, stack pointers and
general purpose registers etc. When an interrupt occurred, information about
the current status of the old process is saved in registers along with the
program counters. This information is necessary to allow the process to be
continued correctly after the completion of an interrupted process.
6. CPU Scheduling Information: This information includes a process priority,
pointers to scheduling queues and any other scheduling parameters.
7. Memory Management Information: This information may include such
information as the value of base and limit registers, the page table or the
segment table depending upon the memory system used by operating system.
8. Accounting: This includes actual CPU time used in executing a process in
order to charge individual user for processor time.
9. I/O Status: It includes outstanding I/O request, allocated devices
information, pending operation and so on.
10. File Management: It includes information about all open files, access
rights etc.
b) Define deadlock and state the necessary conditions for deadlock..
A Deadlock is a situation where each of the computer process waits for a
resource which is being assigned to some another process. In this situation,
none of the process gets executed since the resource it needs, is held by some
other process which is also waiting for some other resource to be released.
Let us assume that there are three processes P1, P2 and P3. There are three
different resources R1, R2 and R3. R1 is assigned to P1, R2 is assigned to P2
and R3 is assigned to P3.
After some time, P1 demands for R1 which is being used by P2. P1 halts its
execution since it can't complete without R2. P2 also demands for R3 which is
being used by P3. P2 also stops its execution because it can't continue without
R3. P3 also demands for R1 which is being used by P1 therefore P3 also stops
its execution.
In this scenario, a cycle is being formed among the three processes. None of the
process is progressing and they are all waiting. The computer becomes
unresponsive since all the processes got blocked.
Swapping
Swapping is a concept in which we do swapping of a process from main
memory to secondary storage and vice-versa. The swapping of processes from
one memory to another is explained clearly in the diagram given below. It
clearly explains that how this swap in and swap out thing works. This is done
so that the memory which we get free through swapping can be used by other
processes.
Swapping affects the performance of the system, but it is helpful or beneficial
for the system when we want to run multiple processes in parallel. Due to this
reason, memory compaction technique is another name given to swapping.
The total time taken by the swapping can be calculated by adding
1. The time is taken in moving the whole process from main memory to
secondary disk.
2. The time is taken in moving back from secondary disk to main memory.
3. Time is taken by the process to regain its main memory
By adding all the above time, we can calculate the total time taken in the whole
process.
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.
Q.
4
a) Compare between Windows and LINUX Operating System.(any four points)
c) Compare between short term and long term scheduler.(any four points)
BASIS FOR LONG-TERM SHORT-TERM
COMPARISON SCHEDULER SCHEDULER
d) Compare FCFS and SJF Scheduling algorithm with any four points.
According to the definition, short processes are executed first and then
followed by longer processes.
The throughput is increased because more processes can be executed in
less amount of time.
And the Disadvantages:
Task scheduler
Schedulers
Schedulers are special system software which handle process scheduling in
various ways. Their main task is to select the jobs to be submitted into the
system and to decide which process to run. Schedulers are of three types −
Long-Term Scheduler
Short-Term Scheduler
Medium-Term Scheduler
User Management
To kill, or terminate a process first find out the process identifier number or
PID of the process to be killed, then pass the PID number to the kill command.
b. Ps 07121975
c. Sleep 05
waiting for 5 seconds
1 3 4 5 1 2 5 1 2 3 4 5 1 6 7 8 7 8 9 7 8 9 5 4 4 5 4 2
2
1 1 1 5 5 5 5 5 5 3 3 3 1 1 1 8 8 8 8 8 8 8 8 4 4 4 4 4
2 2 2
3 3 3 1 1 1 1 1 1 4 4 4 6 6 6 6 6 9 9 9 9 9 9 9 9 9 2
4 4 4 2 2 2 2 2 2 5 5 5 7 7 7 7 7 7 7 7 5 5 5 5 5 5
F F F F F F F F F F F F F F F F F
LRU
1 3 4 5 1 2 5 1 2 3 4 5 1 6 7 8 7 8 9 7 8 8 5 4 4 5 4 2
2
1 1 1 5 5 5 5 5 5 3 3 3 1 1 1 8 8 8 9 9 8 8 8 4 4 4 4 2
2 2 2
33 3 1 1 1 1 1 1 4 4 4 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
4 4 4 2 2 2 2 2 2 5 5 5 7 7 7 7 7 7 7 7 5 5 5 5 5 5
F F F F F F F F F F F F F F F F F F
P1 P2 P3 P4 P5
0 7 11 20 26 34
b) Compare between bitmap and linked list free space management techniques.
(any six
points)
1. Bitmap
This technique is used to implement the free space management. When the
free space is implemented as the bitmap or bit vector then each block of the
disk is represented by a bit. When the block is free its bit is set to 1 and when
the block is allocated the bit is set to 0. The main advantage of the bitmap is it
is relatively simple and efficient in finding the first free block and also the
consecutive free block in the disk. Many computers provide the bit
manipulation instruction which is used by the users.
Disadvantages:
For example: Consider a disk where blocks 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 17, 18,
25,26, and 27 are free and the rest of the blocks are allocated. The free-space
bitmap would be: 001111001111110001100000011100000
2. Linked list
This is another technique for free space management. In this linked list of all
the free block is maintained. In this, there is a head pointer which points the
first free block of the list which is kept in a special location on the disk. This
block contains the pointer to the next block and the next block contain the
pointer of another next and this process is repeated. By using this disk it is not
easy to search the free list. This technique is not sufficient to traverse the list
because we have to read each disk block that requires I/O time. So traversing
in the free list is not a frequent action.
Advantages:
Disadvantages:
Searching the free space list will be very time consuming; each block
will have to be read from the disk, which is read very slowly as
compared to the main memory.
Not Efficient for faster access.
In our earlier example, we see that keep block 2 is the first free block which
points to another block which contains the pointer of the 3 blocks and 3 blocks
contain the pointer to the 4 blocks and this contains the pointer to the 5 block
then 5 block contains the pointer to the next block and this process is repeated
at the last.
c) Construct and explain directory structure of a file system in terms of single
level, two level and tree structure
A directory is a container that is used to contain folders and file. It organizes
files and folders into a hierarchical manner.
There are several logical structures of a directory, these are given below.
1. Single-level directory –
Single level directory is simplest directory structure.In it all files are
contained in same directory which make it easy to support and
understand.
A single level directory has a significant limitation, however, when the
number of files increases or when the system has more than one user.
Since all the files are in the same directory, they must have the unique
name . if two users call their dataset test, then the unique name rule
violated.
Advantages:
Since it is a single directory, so its implementation is very easy.
If files are smaller in size, searching will faster.
The operations like file creation, searching, deletion, updating are
very easy in such a directory structure.
Disadvantages:
There may chance of name collision because two files can not have
the same name.
Searching will become time taking if directory will large.
In this can not group the same type of files together.
2. Two-level directory –
As we have seen, a single level directory often leads to confusion of files
names among different users. the solution to this problem is to create a
separate directory for each user.
In the two-level directory structure, each user has there own user files
directory (UFD). The UFDs has similar structures, but each lists only the
files of a single user. system’s master file directory (MFD) is searches
whenever a new user id=s logged in. The MFD is indexed by username or
account number, and each entry points to the UFD for that user.
Advantages:
We can give full path like /User-name/directory-name/.
Different users can have same directory as well as file name.
Searching of files become more easy due to path name and user-
grouping.
Disadvantages:
A user is not allowed to share files with other users.
Still it not very scalable, two files of the same type cannot be
grouped together in the same user.
3. Tree-structured directory –
Once we have seen a two-level directory as a tree of height 2, the natural
generalization is to extend the directory structure to a tree of arbitrary
height.
This generalization allows the user to create there own subdirectories
and to organize on their files accordingly.
A tree structure is the most common directory structure. The tree has a
root directory, and every file in the system have a unique path.
Advantages:
Very generalize, since full path name can be given.
Very scalable, the probability of name collision is less.
Searching becomes very easy, we can use both absolute path as well
as relative.
Disadvantages:
Every file does not fit into the hierarchical model, files may be saved
into multiple directories.
We can not share files.
It is inefficient, because accessing a file may go under multiple
directories.
4. Acyclic graph directory –
An acyclic graph is a graph with no cycle and allows to share
subdirectories and files. The same file or subdirectories may be in two
different directories. It is a natural generalization of the tree-structured
directory.
It is used in the situation like when two programmers are working on a
joint project and they need to access files. The associated files are stored
in a subdirectory, separated them from other projects and files of other
programmers since they are working on a joint project so they want to
the subdirectories into there own directories. The common
subdirectories should be shared. So here we use Acyclic directories.
It is the point to note that shared file is not the same as copy file if any
programmer makes some changes in the subdirectory it will reflect in
both subdirectories.
Advantages:
We can share files.
Searching is easy due to different-different paths.
Disadvantages:
We share the files via linking, in case of deleting it may create the
problem,
If the link is soft link then after deleting the file we left with a
dangling pointer.
In case of hard link, to delete a file we have to delete all the
reference associated with it.
Advantages:
It allows cycles.
It is more flexible than other directories structure.
Disadvantages:
It is more costly than others.
It needs garbage collection.