OS QB Final Ch-1 To 3 Mid Exam
OS QB Final Ch-1 To 3 Mid Exam
TECHNOLOGY
(DIPLOMA STUDIES)
Operating Systems
(03606205)
Question Bank
Name
Year/Semester
Subject Name
Subject Code
Academic Year
Operating Systems (03606205) PIET-DS
LIST OF QUESTIONS
1. What is Operating System? List out the types of Operating System. (2 marks)
2. Differentiate Multiprogramming OS v/s Multitasking OS. (2 marks)
3. Define Operating System Explain Batch Operating system in Detail. (3 marks)
4. Which are the main services provided by O.S. (2 marks)
5. List various types of O.S. Describe any two types. (3 marks)
6. Explain the need of Operating System. (2 marks)
7. Explain computer system components in details. (3 marks)
8. Explain Time-Sharing Operating Systems –in Detail. (3 marks)
9. Explain Real-Time Operating System –in Detail. (3 marks)
Page No. 2
Operating Systems (03606205) PIET-DS
1. What is Operating System? List out the types of Operating System. (2 marks)
Multiprogramming Multitasking
In multiprogramming, multiple processes Multitasking is when more than one
run concurrently at the same time on a single task is executed at a single time
processor. utilizing multiple CPU'S
It is based on the concept of context It is based on the concept of time
switching sharing
Multiple programs reside in the main It enables execution of multiple tasks
memory simultaneously to improve CPU and processes at the same time to
utilization so that CPU doesn't sit idle for aincrease CPU performance.
long time.
It utilizes single CPU for execution of It utilizes multiple CPUs for task
processes. allocation
It takes more time to execute the processes. It takes less time to execute the tasks
or processes.
Page No. 3
Operating Systems (03606205) PIET-DS
The idea is to reduce the CPU idle time for The idea is to allow multiple processes
as long as possible. to run simultaneously
Page No. 4
Operating Systems (03606205) PIET-DS
Page No. 5
Operating Systems (03606205) PIET-DS
Advantages:
1. TO increase CPU utilization and it never gets idle.
2. Resources are utilized smartly.
3. Less response times
4. Short time jobs are done fastest compare to long time jobs.
5. Multiple users can use multi programming system at once.
Page No. 6
Operating Systems (03606205) PIET-DS
Disadvantages:
1. Memory management is required because all types of jobs are stored
in the main memory.
2. If, it contains massive load of jobs then its long-time jobs have to
need long waiting time.
3. Harder task is to manage of all processes and jobs.
4. It is highly complex and sophisticated.
6. Explain the need of Operating System. (2 marks)
The main goals of the Operating System are: (i) To make the computer system
convenient to use, to make the use of computer hardware in efficient way.
Operating System may be viewed as collection of software consisting of
procedures for operating the computer and providing an environment for
execution of programs.
An operating system has three main functions:
❖ manage the computer's resources, such as the central processing unit,
memory, disk drives, and printers,
❖ establish a user interface, and
❖ execute and provide services for applications software.
7. Explain computer system components in details. (3 marks)
A Computer system can be divided into four components
Page No. 7
Operating Systems (03606205) PIET-DS
system, games, and business programs. They define the way in which the
hardware resources are to be used to solve the computing problems of the users.
❖ Users: There are many different users trying to solve different problems
using different application programs.
8. Explain Time-Sharing Operating Systems –in Detail. (3 marks)
❖ It is a logical extension of multiprogramming operating system.
❖ The ability to execute more than one task at the same time, a task being a
program is called multitasking.
❖ The terms multitasking and multiprocessing are often used interchangeably
although multiprocessing implies that more than one CPU is involved.
❖ A time – shared operating system uses CPU scheduling and
multiprogramming to provides each user with a small portion of a time – shared
computer. Each user has at least one separate program in memory.
Advantages
❖ The advantages of time-sharing operating system are as follows −
❖ In time sharing each process gets equal opportunity to execute because equal
time quantum is given to each process.
❖ The CPU is always busy because of maintaining time slots, there is no
wastage of CPU time.
Disadvantage
Page No. 8
Operating Systems (03606205) PIET-DS
Page No. 9
Operating Systems (03606205) PIET-DS
❖ Hard real time: In Hard RTOS, the deadline is handled very strictly which
means that given task must start executing on specified scheduled time, and
must be completed within the assigned time duration.
❖ Example: Medical critical care system, Aircraft systems, etc.
❖ soft real time: Soft Real time RTOS, accepts some delays by the Operating
system. In this type of RTOS, there is a deadline assigned for a specific job,
but a delay for a small amount of time is acceptable. So, deadlines are handled
softly by this type of RTOS.
❖ Example: Online Transaction system and Livestock price quotation System.
Page No. 10
Operating Systems (03606205) PIET-DS
Program Process
It is a well-organized set of The execution of a program is
instructions. referred to as a process.
A programme is a passive/static A process is a living, breathing
entity. entity.
A program's lifespan is longer. The lifespan of a process is finite.
NEW
∙ A process that has just created by the O.S., but not submit into the Queue for
execution. ∙ The new born process comes to this state.
READY
When the new born process comes into the main memory and it is ready to
execute that the process is called in ready state.
Here, Process execution is not started but the process is ready for run or
Page No. 11
Operating Systems (03606205) PIET-DS
Process ID
Program Counter
Process state
Priority
Page No. 12
Operating Systems (03606205) PIET-DS
Page No. 13
Operating Systems (03606205) PIET-DS
15. What are the three major activities of an operating system with regard to
memory management? 2 marks
o The three major activities are:
o Keep track of which parts of memory are currently being used and by
whom.
o Decide which processes are to be loaded into memory when memory
space becomes available.
o Allocate and deal locate memory space as needed.
16. Types of schedulers? 4 marks
The process scheduling is the activity of the process manager that handles the removal
of the running process from the CPU and the selection of another process on the basis of
Page No. 14
Operating Systems (03606205) PIET-DS
There are three types of process scheduler. Long Term or job scheduler:
It brings the new process to the ‘Ready State’. It controls Degree of Multi-programming,
i.e., number of processes present in ready state at any point of time. It is important that
the long-term scheduler make a careful selection of both I/O and CPU-bound processes.
I/O bound tasks are which use much of their time in input and output operations while
CPU bound processes are which spend their time on CPU. The job scheduler increases
efficiency by maintaining a balance between the two.
Page No. 15
Operating Systems (03606205) PIET-DS
Scheduling
Out of the many processes present in the ready queue, the Operating system chooses one
process and start executing it. Selecting the process which is to be executed next, is known
as scheduling.
Execution
Once the process is scheduled for the execution, the processor starts executing it. Process
may come to the blocked or wait state during the execution then in that case the processor
starts executing the other processes.
Deletion/killing
Once the purpose of the process gets over then the OS will kill the process. The Context
of the process (PCB) will be deleted, and the process gets terminated by the Operating
system.
It is the most important function of an operating system that manages primary memory.
It helps processes to move back and forward between the main memory and execution
disk. It helps OS to keep track of every memory location, irrespective of whether it is
allocated to some process or remains free.
Page No. 16
Operating Systems (03606205) PIET-DS
Partitioned Allocation
First Fit: In this type fit, the partition is allocated, which is the first sufficient
block from the beginning of the main memory.
Best Fit: It allocates the process to the partition that is the first smallest partition
among the free partitions.
Worst Fit: It allocates the process to the partition, which is the largest sufficient
freely available partition in the main memory.
Page No. 17
Operating Systems (03606205) PIET-DS
Next Fit: It is mostly similar to the first Fit, but this Fit, searches for the first
sufficient partition from the last allocation point.
Benefits of Swapping
Here, are major benefits/pros of swapping:
It offers a higher degree of multi programming.
Allows dynamic relocation. For example, if address binding at execution time is being
used, then processes can be swap in different locations. Else in case of compile and load
time bindings, processes should be moved to the same location.
After sometimes, that processes not able to allocate to memory blocks because its small
Page No. 18
Operating Systems (03606205) PIET-DS
size and memory blocks always remain unused is called fragmentation. This type of
problem happens during a dynamic memory allocation system when free blocks are quite
small, so it is not able to fulfill any request.
Internal fragmentation
Segmentation method works almost similarly to paging. The only difference between the
two is that segments are of variable-length, whereas, in the paging method, pages are
always of fixed size. ∙ A program segment includes the program’s main function, data
structures, utility functions, etc.
The OS maintains a segment map table for all the processes. It also includes a list of free
memory blocks along with its size, segment numbers, and its memory locations in the
main memory or virtual memory.
Page No. 19
Operating Systems (03606205) PIET-DS
Less flexible, as any updates or changes to the More flexible, as libraries can be updated or
libraries require recompilation and relinking replaced without recompiling the program.
of the entire program.
Slightly slower program startup due to the
Faster program startup and direct execution, additional linking process, but overall
as all libraries are already linked. performance impact is minimal.
Executables with file extensions like .exe,. Executables with file extensions like .dll, .so,
elf,. a, .lib, etc. .dylib, etc.
Page No. 20
Operating Systems (03606205) PIET-DS
The operating system can provide a logical view of the information stored in the disks,
this logical unit is known as a file. The information stored in files is not lost during
power failures. ∙ A file helps to write data on the computer. It is a sequence of bits,
bytes, or records, the structure of which is defined by the owner and depends on the
type of the file.
File Attributes
Name: It is the only information stored in a human-readable form.
Identifier: Every file is identified by a unique tag number within a file system
known as an identifier. ∙ Location: Points to file location on device.
Type: This attribute is required for systems that support various types of files.
Size: Attribute used to display the current file size.
Time, date and security: It is used for protection, security, and also used for monitoring
1. Sequential access
Records are accessed in a per-defined order in this type of file access method.
Information stored in the file is also processed one by one using the sequential access
method.
This is the most common way for compilers to access files.
Page No. 21
Operating Systems (03606205) PIET-DS
Page No. 22
Operating Systems (03606205) PIET-DS
❖ Directory structure
Single-level directory
The simplest directory structure is a single-level directory.
All files are contained in the same directory, making it simple to maintain and
understand.
When the number of files grows or the system has more than one user, a single level
directory becomes a significant limitation. Because all of the files are in the same
directory, they must all be named differently.
The unique name rule is broken if two users call their dataset test.
Page No. 23
Operating Systems (03606205) PIET-DS
Advantage
Simple
Easy to search
Disadvantage
Not suitable for multiuser system
No. of files becomes too large
Diff files can’t be grouped
30. Explain file structure.
Page No. 24
Operating Systems (03606205) PIET-DS
The basic file system level works directly with the device drivers in terms of
retrieving and storing raw blocks of data, without any consideration for what is in
each block.
It sends device driver general commands to read and write physical blocks on
disc.
It is responsible for memory buffers and caches.
• File organization Module :
o It contains data on files, their locations, and their logical and physical
blocks. Physical blocks do not correspond to logical block numbers
ranging from 0 to N. There's also a free space that keeps track of
unallocated blocks.
• Disadvantages :
When we access multiple files at the same time, the performance suffers
• When files are created, the system keeps track of the free disc blocks
and allocates space to them.
• Free space management is also important for repurposing the
Page No. 25
Operating Systems (03606205) PIET-DS
• A Bitmap or Bit Vector is series or collection of bits where each bit corresponds
to a disk
• block. The bit can take two values: 0 and 1: 0 indicates that the block is allocated
and 1 indicates a free block.
• The given instance of disk blocks on the disk in Figure 1 (where green blocks are
allocated)can be represented by a bitmap of 16 bits as: 0000111000000110.
● In this approach, the free disk blocks are linked together i.e. a free block contains a
pointer to the next free block.
● The block number of the very first disk block is stored at a separate location
on disk and is also coached in memory.
Grouping:
• This approach stores the address of the free blocks in the first free block.
• The first free block stores the address of some, say n free blocks.
• Out of these n blocks, the first n -1 blocks are actually free and the last
block co ntains the address of next free n blocks.
• This method has the advantage of making it simple to locate the addresses
of a group of free disc blocks.
Counting
This approach stores the address of the first free disk block and a number n of free
contiguous disk blocks that follow the first block. Every entry in the list would contain:
1. Address of first free disk block
2. A number n
Page No. 26
Operating Systems (03606205) PIET-DS
Linked List
In this approach, the free disk blocks are linked together i.e. a free block contains a
pointer to the next free block. The block number of the very first disk block is stored at
a separate location on disk and is also cached in memory.
list head points to Block 5 which points to Block 6, the next free
block and so on. The last free block would contain a null pointer indicating the end of free
list. A drawback of this method is the I/O required for free space list traversal.
Mounting:
a. mounting means attaching files to the file system so that we can use those file at that
filesystem.
b. mounting is process by using which operating system makes files and directory
available at its specific path so that we can make all use of files and directories at
their specific path. Before you can access the files on a file system, you need to mount
the file system.
c. Mounting a file system attaches that file system to a directory (mount point)
and makes it available to the system.
d. the root (/) file system is always mounted. Any other file system can be
connected or disconnected from the root (/) file system.
e. For example, the figure below shows a local file system, starting with a root (/)
file systemand sub directories sbin, etc, and opts.
f. Now, say you wanted to access a local file system from the /opt file system that
contains a set of unbundled products.
g. First, you must create a directory to use as a mount point for the file system you
want to mount, for example, /opt/unbundled. Once the mount point is created, you
can mount the file system (by using the mount command), which makes all of the
files and directories in/opt/unbundled available, as shown in the figure below.
Page No. 27
Operating Systems (03606205) PIET-DS
Page No. 28
Operating Systems (03606205) PIET-DS
Extra
A.write a shell script to multiply 2 numbers.
#!/bin/bash
OUTPUT:
$ sh multiply.sh Enter num1:
10
Enter num2:
5
Multiplication is: 50
src="$1" dst="$2"
while read line; do
for word in $line; do
if ! grep -q "\ b$word" $dst; then echo -n "$word " >> $dst
fi done
echo " " >> $dst done
Page No. 29
Operating Systems (03606205) PIET-DS
P1 0 15
P2 2 10
P3 4 5
P4 8 8
Arrival Turnaround
Burst Completion Waiting time
Process Time Time
Time(BT) Time (CT) =TAT- BT
(AT) (TAT=CT-AT)
P1 0 15 15 15 0
P2 2 10 25 23 13
P3 4 5 30 26 21
P4 8 8 38 30 22
=23.5ms
Page No. 30
Operating Systems (03606205) PIET-DS
P1 0 15
P2 2 10
P3 4 5
P4 8 8
Implementation: Processes will execute in a FIFO manner, but each process will execute only for
a given time interval. It is also called time slice or time quantum.
If a process needs more time to complete after time slice, it is placed at the end of the ready queue
to wait for the next allocation
Example: -Suppose the following processes are in queue and submission time and the required
execution time for each process is given below. And the time interval is 5ms. And context switch
overhead is 1ms.
Process P1 will execute first for 5ms. And after a completion time interval, P1 will stop and P2 will
start for 5ms.
P1 will go at the end of the queue and waiting for the next allocation. · 1ms will need to switch next
process. After completion of the time interval of P2, P3 will start for execution at 12ms.here context
switch overhead will be of 1ms.
All processes will execute in order of arrival. This procedure will repeat for all processes of the queue.
After the execution of all processes, Statistics will be as under for each process
Burst Completion Turnaround
Arrival Time Waiting time
Process Time Time Time
(AT) TAT- BT
(BT) (CT) (TAT=CT-AT)
Page No. 31
Operating Systems (03606205) PIET-DS
P1 0 15 41 41 26
P2 2 10 35 33 23
P3 4 5 17 13 8
P4 8 8 45 37 29
Page No. 32