0% found this document useful (0 votes)
38 views32 pages

OS QB Final Ch-1 To 3 Mid Exam

The document contains a list of questions related to operating systems for a diploma course. It covers topics like basics of operating systems, process management, and file management. Some key points: 1) The first section defines operating systems and lists common types like batch, multiprogramming, real-time, and multitasking systems. It also explains batch systems and time-sharing systems. 2) Process management concepts like process life cycle, scheduling, and memory management techniques like paging, segmentation, and swapping are covered. 3) File management topics include file concepts, access methods, file structures, and free space management.

Uploaded by

Junaid Bhulecha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views32 pages

OS QB Final Ch-1 To 3 Mid Exam

The document contains a list of questions related to operating systems for a diploma course. It covers topics like basics of operating systems, process management, and file management. Some key points: 1) The first section defines operating systems and lists common types like batch, multiprogramming, real-time, and multitasking systems. It also explains batch systems and time-sharing systems. 2) Process management concepts like process life cycle, scheduling, and memory management techniques like paging, segmentation, and swapping are covered. 3) File management topics include file concepts, access methods, file structures, and free space management.

Uploaded by

Junaid Bhulecha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

PARUL INSTITUTE OF ENGINEERING &

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

Unit 1: Basics of Operating System

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)

Unit 2: Process Management

10. What is program and process? (2 marks)


11. Explain process life cycle. (4 marks)
12. Explain Process Control Block. (4 marks)
13. What is process scheduling criteria? (2 marks)
14. Explain Inter Process Communication. (4 marks)
15. What are the three major activities of an operating system with regard to memory
management? (2 marks)
16. Types of schedulers? (4 marks)
17. What is the operation performed on the process? (3 marks)
18. What is memory management? (3 marks)
19. Memory management techniques (Types of memory Allocation) (4 marks)
20. What is swapping? Benefits of Swapping. (3 marks)
21. What is Paging? (2 marks)
22. What is Fragmentation? (3 marks)
23. What is Segmentation? (2 marks)
24. Difference between Static and Dynamic loading. (2 marks)

Unit 3: File management

25. Explain Concepts of File. (2 marks)


26. Explain is Access Method in brief. (3 marks)
27. List out different type of file? (2 marks)
28. Define directory structure and Explain Single level directory .(3 marks)
29. Explain file structure.(3 or 4 marks)
30. Explain free space management.(4 marks)
31. Write short note File system mounting.
32. Explain file structure.

Page No. 2
Operating Systems (03606205) PIET-DS

Unit 1: Basics of Operating System

1. What is Operating System? List out the types of Operating System. (2 marks)

An Operating System (OS) is a software that acts as an interface between


computer hardware components and the user. An Operating System (OS) is an
interface between a computer user and computer hardware. An operating
system is a software which performs all the basic tasks like file management,
memory management, process management, handling input and output, and
controlling peripheral devices such as disk drives and printers. Some popular
Operating Systems include Linux Operating System, Windows Operating
System. An operating system is a program that acts as an interface between the
user and the computer hardware and controls the execution of all kinds of
programs.

Types of Operating System:


1. Batch Operating System:
2. Multiprogramming Operating System:
3. Real Time Operating System
4. Multitasking Operating System Or Time – Sharing O.S.:
5. Multithreading Operating System

2. Differentiate Multiprogramming OS v/s Multitasking OS. (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

3. Explain Batch Operating system in Detail. (3 marks)


This type of operating system does not interact with the computer directly.
There is an operator which takes similar jobs having the same requirement and
group them into batches. It is the responsibility of the operator to sort jobs with
similar needs.
The First operating system of the second-generation computer is the batch
operating system. Batch operating system took the input on the punch card.
Each punch card had the different form of data. System executed the jobs one
by one in batch. When one job from the batch executed, then the second job
has taken from it and so on. The process of placing the jobs in queue for
execution is known as spooling.

How its work:


OS keeps the number of jobs in memory and executes them one by one. Jobs
processed in first come first served order. Each set of a job considered as a
batch.
When a job completes its execution, its memory is released, and the output for
the job gets copied into an output spool for later printing or processing.
User interaction in the batch processing system is minimal. One’s system
accepts the jobs from users, and then the user is free. That is why we can use
batch processing system in large organizations in these days. The batch
processing system used where we want to update the data related to any
transactions or any record. Transactions can be related to any customer orders,

Page No. 4
Operating Systems (03606205) PIET-DS

receipts, invoices, payments, online transactions, data entry, payroll system,


banks etc.
Advantages:
1) Same jobs in the batch are higher executed speed.
2) A process is complete its execution, next job from job spool get
executed without any user interaction.
3) CPU utilization gets improved.
4) To speed up the processing speed, the batch process can partition
into the number of processes. ∙
Disadvantages:
1) Difficult to debug.
2) If a job gets to enter in an infinite loop, other jobs wait for unknown
time.
3) Batch systems are costly.

4. Which are the main services provided by O.S. (2 marks)


The operating system provides the programming environment in which a
programmer works on a computer system. The user program requests various
resources through the operating system.
 Following are the services provided by an operating system -
• Program execution
• Control Input/output devices
• Program creation
• Error Detection and Response
• Accounting
• Security and Protection
• File Management
• Communication
5. List various types of O.S. Describe any two types. (3 marks)
∙ Types of Operating System
1. BATCH OPERATING SYSTEM:

Page No. 5
Operating Systems (03606205) PIET-DS

2. MULTIPROGRAMMING OPERATING SYSTEM:


3. REAL TIME OPERATING SYSTEM
4. MULTITASKING OPERATING SYSTEM OR TIME – SHARING O.S.:
5. MULTITHREADING OPERATING SYSTEM
MULTIPROGRAMMING OPERATING SYSTEM:
 Multiprogramming OS is an ability of an operating system that executes
more than one program using a single processor machine.
 More than one task or program or jobs are present inside the main
memory at one point of time. In the multiprogramming system, one or
multiple programs can be loaded into its main memory for getting to
execute.
 It is capable only one program or process to get CPU for executes for
their instructions, and other programs wait for getting their turn.
 Main goal of using of multiprogramming system is overcome issue of
underutilization of CPU and primary memory.

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

❖ Hardware: The hardware of computer system includes the Central


Processing Unit (CPU), the memory, and the input/output (I/O) devices. They
are the basic resources.
❖ Operating System: The operating system controls and coordinates the user
of the hardware among the various application programs for the various users.
❖ Application Programs: application program includes compilers, database

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

❖ The disadvantage of time-sharing operating system is as follows −


❖ In the Time-sharing operating system the process having higher
priority does not get the chance to be executed first. This is because an
equal priority is given to each process.
9. Explain Real-Time Operating System –in Detail. (3 marks)
❖ RTOS is stands for “Real time operating system”, and it is also known as
embedded operating system. Real time operating system is totally depending
upon the clock interrupts. This system produces the Interrupt Service Routine
(ISR) interrupts.
❖ RTOS implemented the Priority system for executing all types of process.
Entire RTOS is synchronized with the process, and they can make
communication in between all process.
❖ RTOS always controls inputs and respond within defined time constraint.
❖ Systems that control scientific experiments, medical imaging systems,
industrial control systems, and some displays, automobile-engine fuel-
injection system are real-time system.

❖ A real-time operating system has well-defined, fixed time constraints


processing must be done with the defined constraints, or the system will fail.
❖ There are two flavors of real-time systems:

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.

Extra: Explain Characteristics of Operating System. (2 marks)


∙ Memory Management — It keeps tracks of primary memory i.e., what part of
it are in use by whom, what part are not in use etc. Allocates the memory when
the process or program request it. ∙ Processor Management — Allocate the
processor (CPU) to a process. Deallocate processor when processor is no longer
required.
∙ Device Management — Keep tracks of all devices. This is also called I/O
controller. Decides which process gets the device when and for how much time.
File Management — Allocates the resources. De-allocates the resource.
Decides who gets the resources.
∙ Security — By means of passwords & similar other techniques, preventing
unauthorized access to programs & data.
∙ Error-detecting aids — Production of dumps, traces, error messages and other
debugging and error detecting methods.

Page No. 10
Operating Systems (03606205) PIET-DS

Unit 2: Process Management


10. What is program and process? (2 marks)

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.

A program is saved on a hard drive. A process necessitates memory,


disc space, and a processor, among
other things.
On disc, a program only stores A process keeps track of program
instructions. code, data, and the stack.

11. Explain Process life cycle with diagram (4 marks)

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

execute. During the execution if any interrupt generate by system or process


is timeout than it will send back to Ready state.
RUNNING
 When process is currently executing by processor then its state is called
Running state. ∙ Dispatcher will provide process to processor for
execution. At a time only one process can be executed. ∙ The execution
of process can be stopped by any I/O interrupt or by process time out.
BLOCKED
 When Process is under execution and during execution period if any
event or I/O interrupt comes than the process will be send to block
state.
 As process finished its all I/O interrupt and time out phase that the
process will be again send to ready state.
EXIT
 Once the process finished the execution of process, it will be released
by the processor. ∙ It is called as terminated state or exit state.
12. Explain Process Control Block.( 4 marks)
A process control block is a data structure maintained by the operating system.
System for every process:
 The PCB is identified by an integer process ID(PID)
 A PCB keeps all the information needed to keep track of a process
 Every process has its own PCB to store information related to state,
which line is executed etc.,

Process ID
Program Counter

Process state

Priority

General Purpose Registers

Page No. 12
Operating Systems (03606205) PIET-DS

List of Open Files

List of Open Devices


Process ID
A unique id is assigned to each process when it is formed, and this id is used
to identify the process throughout the system.
Program Counter
A program counter stores the address of the last instruction of the process on
which the process was suspended.
The CPU uses this address when the execution of this process is resumed.
Process state
The Process, from its creation to the completion, goes through various states
which are new, ready, running and waiting.
Priority
Every process has its own priority. The process with the highest priority among
the processes gets the CPU first. This is also stored on the process control block
General Purpose Registers
Every process has its own set of registers which are used to hold the data which
is generated during the execution of the process.
List of Open files
During the execution, every process uses some files which need to be present
in the main memory. OS also maintains a list of open files in the PCB.
List of open devices
OS also maintain the list of all open devices which are used during the
execution of the process.
13. What is process scheduling criteria? 2 marks
Scheduling is the process of making a choice of which process to run next
whenever more than one process are simultaneously in the ready state.
Scheduling is very important.
The reason is it can have a big effect on resource utilization and the overall
performance of the system.

Page No. 13
Operating Systems (03606205) PIET-DS

14. Explain Inter Process Communication. (4 marks)


Multi programming operating system has more than one processes, processes can
communicate with each other in system.
Sometime output of one process can be input of other process. Printing of process
of one computer can be performed by other process on another computer in network.
These are examples of communication of processes’ is a mechanism which provides
the communication between the processes.
IPC provide this communication using message passing system. Processes are
communicated with each other by sending or receiving the message. Issues in IPC:
- Process need to use shared memory for data sharing Two or more process can be
in each other’s way. Proper scheduling required.
Advantages: -
 Information Sharing
 Message passing
 Computation Speed up
 Modularity.
Disadvantages: -
 Race problem like Race condition
 Need good Synchronization.

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

a particular strategy. ∙ Process scheduling is an essential part of a Multi programming


operating systems. Such operating systems allow more than one process to be loaded into
the executable memory at a time and the loaded process shares the CPU using time
multiplexing.

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.

Short term or CPU scheduler:


It is responsible for selecting one process from ready state for scheduling it on the
running state. Note: Short-term scheduler only selects the process to schedule it
doesn’t load the process on running. Here is when all the scheduling algorithms
are used. The CPU scheduler is responsible for ensuring there is no starvation
owing to high burst time processes.

Dispatcher is responsible for loading the process selected by Short-term scheduler


on the CPU (Ready to Running State) Context switching is done by dispatcher
only. A dispatcher does the following: ∙ Switching context.

∙ Switching to user mode.


∙ Jumping to the proper location in the newly loaded program.
∙ Medium-term scheduler:
It is responsible for suspending and resuming the process. It mainly does swap
(moving processes from main memory to disk and vice versa). Swapping may be
necessary to improve the process mix or because a change in memory
requirements has over committed available memory, requiring memory to be
freed up. It is helpful in maintaining a perfect balance between the I/O bound and
the CPU bound. It reduces the degree of multi programming.

Page No. 15
Operating Systems (03606205) PIET-DS

17. What is the operation performed on the process? 3 marks


Creation
Once the process is created, it will be ready and come into the ready queue (main memory)
and will be ready for the execution.

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.

18. What is memory management? (3 marks)


Memory Management is the process of controlling and coordinating computer memory,
assigning portions known as blocks to various running programs to optimize the overall
performance of the 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.

19. Types of memory Allocation (4 marks)

Page No. 16
Operating Systems (03606205) PIET-DS

Single Contiguous Allocation


It is the easiest memory management technique. In this method, all types of
computer’s memory except a small portion which is reserved for the OS is
available for one application. For example, MS-DOS operating system allocates
memory in this way. An embedded system also runs on a single application.

Partitioned Allocation

It divides primary memory into various memory partitions, which is mostly


contiguous areas of memory. Every partition store all the information for a specific
task or job. This method consists of allotting a partition to a job when it starts &
unallocated when it ends.

Memory is divided into different blocks or partitions. Each process is allocated


according to the requirement. Partition allocation is an ideal method to avoid
internal fragmentation. ∙ Below are the various partition allocation schemes:

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.

20. What is swapping? Benefits of Swapping. (3 marks)


Swapping is a method in which the process should be swapped temporarily from the main
memory to the backing store. It will be later brought back into the memory for continue
execution. ∙ Backing store is a hard disk or some other secondary storage device that
should be big enough in order to accommodate copies of all memory images for all users.
It is also capable of offering direct access to these memory images.

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.

It helps to get better utilization of memory.


Minimum wastage of CPU time on completion so it can easily be applied to a priority-
based scheduling method to improve its performance.

21. What is Paging? (2 marks)


Paging is a storage mechanism that allows OS to retrieve processes from the secondary
storage into the main memory in the form of pages. In the Paging method, the main
memory is divided into small fixed-size blocks of physical memory, which is called
frames. The size of a frame should be kept the same as that of a page to have maximum
utilization of the main memory and to avoid external fragmentation. Paging is used for
faster access to data, and it is a logical concept.

22. What is Fragmentation? (3 marks)


Processes are stored and removed from memory, which creates free memory space,
which are too small to use by other processes.

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.

Two types of Fragmentation methods are:


External fragmentation
External fragmentation can be reduced by rearranging memory contents to place
all free memory together in a single block.

Internal fragmentation

The internal fragmentation can be reduced by assigning the smallest partition,


which is still good enough to carry the entire process.

23. What is Segmentation? (2 marks)

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.

24. Difference between Static and Dynamic loading.

Static Loading Dynamic Loading


Static loading is used to load the entire It refers to the process of loading any program
program in the main memory before in the main memory according to the
executing that program conditions.
In Dynamic loading, all the necessary,
It doesn’t need any additional software to
modules and libraries are pre-loaded on the
compile the entire program.
system.
It is more secure and more system resources It is less secure but system resources consume
are consumable. only when needed.

Page No. 19
Operating Systems (03606205) PIET-DS

The processing speed of the static loading is


The processing speed is slower compared to
faster when the files update during processing
then.
time.
Limited flexibility because all libraries are More flexible because libraries can be loaded
loaded at once. on demand.
Requires a recompilation and re-linking for Allows for dynamic updates without the need
any program change. for recompilation.
After loading the code in the main memory it After loading the code in memory execution
might be executed. is required when it is.
For example- static loading happened in a For example – the Dynamic loading in the
structured programming language like C. OOPs language like Java, C++

25. Difference between Static and Dynamic linking.

Static linking Dynamic linking


The process of linking external libraries and
The process of combining all necessary
references at runtime, when the program is
library routines and external references into a
loaded or executed.
single executable file at compile-time.
Occurs at compile-time. Occurs at runtime
Smaller file size, as libraries are linked
Generally larger file size, as all required
dynamically at runtime.
libraries are included in the executable.

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

Unit 3: File management

26. Explain Concepts of File. (2 marks)


The file can be explained as the smallest unit of storage on a computer system. The
user can perform file operations like open, close, read, write, and modify.

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

27. Explain Access Method in brief. (3 marks)


File access is a process that determines the way that files are accessed and read into
memory. Generally, a single access method is always supported by operating systems.
Though there are some operating system which also supports multiple access methods.

❖ Three file access methods are:

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

Figure: 3.1 Sequential Access


2.Random Access:
Direct random access is another name for the random-access method.
This method enables direct access to the record.
Each record has a unique address that can be accessed directly for reading and writing.

Figure: 3.2 Random Access


3. Index sequential access
Simple sequential access is used in this type of accessing method.
For each file, an index is created with a direct pointer to different memory blocks in this
access method.
The Index is searched sequentially in this method, and its pointer can directly access the
file.
To improve access efficiency, multiple levels of indexing can be used.
It also cuts down on the amount of time it takes to access a single record.

Figure: 3.3 Example of Indexed Allocation

4.Relative Record Access –


Relative record access is a file access method used in operating systems where records
are accessed relative to the current position of the file pointer. In this method,
records are located based on their position relative to the current record, rather than
by a specific address or key value.

Page No. 22
Operating Systems (03606205) PIET-DS

28. List out different type of file? (2 marks)


1. Character Special File
2. Ordinary files
3. Directory Files
4. Special Files
29. Define directory structure and Explain Single level directory .(3 marks)
Directory can be defined as the listing of the related files on the disk. The directory may
store some or the entire file attributes.
To get the benefit of different file systems on the different operating systems, A hard
disk can be divided into the number of partitions of different sizes. The partitions are
also called volumes or mini disks. Each partition must have at least one directory in
which, all the files of the partition can be listed. A directory entry is maintained for
each file in the directory which stores all the information related to that file.

❖ Directory structure

❖ Single level directory

❖ Two level directory

❖ Tree structured directories

❖ Acyclic Graph Directory

❖ General Graph Directory

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.

• I/O Control Level :


I/ O Control consists of device drivers, special software programs ( often
written in assembly ) which communicate with the devices by reading and
writing special codes Device drivers acts as interface between devices and Os,
they help to transfer data between disk and main memory. It takes block
number a input and as output it gives low level hardware specific
instruction

Page No. 24
Operating Systems (03606205) PIET-DS

• I/ O Control consists of device drivers, special software programs ( often written in


assembly ) which communicate with the devices by reading and writing special codes
Device drivers acts as interface between devices and Os, they help to transfer data
between disk and main memory. It takes block number a input and as output it gives
low level hardware specific instruction

• Basic file system :

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.

• Logical file system :

o It manages a file's metadata information, w hich includes all information about


the file except the actual contents. It also keeps track of files using file control
blocks. The file control block (FCB) contains information about a file, such as
its owner, size, permissions, and content location.
• Advantages :

o Code duplication is kept to a minimum.

o A logical file system can be created for each file system.

• Disadvantages :

When we access multiple files at the same time, the performance suffers

31. Explain free space management. (4 marks)

Free space management:

• 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

space freed up by deleting files.


• The system keeps track of the disc blocks that aren't assigned to any
file or directory in a free space list.
• The free space list can be implemented in a variety of ways, the most common
of which are:

1) Bitmap or Bit vector:

• 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.

32. Write short note File system mounting.

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

# Program name: "multiply.sh"


# Linux shell script program to multiply two numbers .

echo "Enter num1: " read num1


echo "Enter num2: " read num2

multiply=`expr $num1 \ * $num2` echo "Multiplication is: $multiply"

OUTPUT:
$ sh multiply.sh Enter num1:
10
Enter num2:
5
Multiplication is: 50

A. write a shell script to append content of one file to another.


#!/bin/bash

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

Example : average waiting time and average turnaround time


using FCFS scheduling algorithm.

Process Arrival Time Burst Time

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

Average Waiting Time


= (0+13+21+22)/4
=19ms

Average Turnaround Time = (15+23+26+30)/4

=23.5ms

Page No. 30
Operating Systems (03606205) PIET-DS

Explain any one scheduling algorithm with example.

Process Arrival Completion


Time Time

P1 0 15

P2 2 10

P3 4 5

P4 8 8

This is a pre-emptive scheduling algorithm.

In round-robin processes will execute for a given time interval.

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.

Figure: 2.4 (b) Gantt Chart for RR

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

Average Turnaround Time=


(41+33+13+37)/4=31ms

Average Waiting Time=


(26+23+8+29)/4=21.5ms

Page No. 32

You might also like