OS
OS
1.Mutual Exclusion
At least one resource must be held in a non-shareable mode. This means that only one process can
use the resource at any given time. If another process requests the same resource, it must wait until
the resource is released.
Example: A printer (resource) can only be used by one process at a time, so if one process is using it,
others must wait.
A process that is holding at least one resource is waiting to acquire additional resources that are
currently being held by other processes.
Example: Process A holds a printer (resource) and is waiting for a scanner (another resource) that is
held by Process B. Process B, meanwhile, is holding the scanner and waiting for the printer.
3. No Preemption
Resources cannot be forcibly taken away from processes holding them. Once a process holds a
resource, it cannot be preempted (i.e., taken from it by force) until it releases the resource
voluntarily.
Example: If a process is holding a resource and is not finished with it, no other process or the
operating system can forcibly take it away, even if other processes are waiting for that resource.
4. Circular Wait
A set of processes exist such that each process is waiting for a resource that is held by the next
process in the set, forming a circular chain.
Example: Process A is waiting for a resource held by Process B, Process B is waiting for a resource
held by Process C, and Process C is waiting for a resource held by Process A. This creates a cycle
where no process can proceed.
Virtual Memory-2M
Virtual memory is a memory management technique used by modern operating systems to give an
application the illusion of having access to a large, contiguous block of memory, even if the physical memory
(RAM) is limited. It allows programs to address more memory than is physically available by using a
combination of main memory (RAM) and disk storage (usually on a hard drive or SSD).
Paging is a memory management scheme that eliminates the need for contiguous memory allocation. In
paging, the virtual memory is divided into fixed-size blocks called pages, while the physical memory is divided
into fixed-size blocks called frames. The size of a page is typically the same as the size of a frame.
2) I/O-bound Program
An I/O-bound program is a program whose performance is primarily limited by the speed of I/O operations,
such as reading or writing data to disk, interacting with network devices, or waiting for user input. These
programs spend much of their time waiting for data from I/O devices rather than performing intensive
calculations.
1. CPU Utilization
Definition: CPU utilization refers to the percentage of time the CPU is actively being used. The goal
is to keep the CPU as busy as possible to maximize system throughput.
2. Throughput
Definition: Throughput is the number of processes completed (or jobs finished) per unit of time.
3. Turnaround Time
Definition: Turnaround time is the total time taken from the submission of a process to its
completion. It includes both waiting time and execution time.
4. Waiting Time
Definition: Waiting time is the total time a process spends in the ready queue waiting for CPU time,
excluding the time spent executing on the CPU.
describe concept of free space management technique using bit map method-4M
In an operating system, free space management refers to the technique used to track which blocks (or pages)
of storage are currently free (unallocated) and which are occupied (allocated). The primary goal of free space
management is to efficiently utilize storage space by minimizing fragmentation and ensuring that the system
can quickly allocate and deallocate storage blocks as needed.
How It Works
Simple and Efficient, Fast Allocation and Deallocation, Compact Representation, efficient Space Management
Fragmentation refers to the condition where storage space is used inefficiently, leading to wasted space. It
typically occurs when free memory or storage is divided into small, non-contiguous blocks, preventing
efficient allocation of resources. Fragmentation can affect both memory (RAM) and disk storage. There are
two main types of fragmentation:
1. Internal Fragmentation
2. External Fragmentation
1) Internal Fragmentation
Definition: Internal fragmentation occurs when the memory or storage block allocated to a process or file is
larger than the space required. As a result, the extra space within the allocated block remains unused, leading
to wasted space within the block.
2) External Fragmentation
Definition: External fragmentation occurs when free memory or storage is split into small, non-contiguous
blocks scattered across the system. Even though there may be enough total free space available to satisfy a
request, it cannot be allocated because the free space is fragmented into smaller blocks that are not
contiguous.
Definition: In fixed memory management, the memory is divided into fixed-size partitions before the system
starts running. Each partition is a specific, predefined size, and it can hold only one process at a time. The
number of partitions is fixed, and the system does not change the size of these partitions during execution.
Definition: In variable memory management, the system allocates memory dynamically based on the size of
the process. The memory is divided into partitions that can vary in size, depending on the needs of the
processes. A process is allocated exactly as much memory as it requires, and the partitions are created and
managed as needed.
draw and explain directory structure of a file system in terms of single level, two level and tree level
A directory is a container that is used to contain folders and files. It organizes files and folders in a
hierarchical manner. In other words, directories are like folders that help organize files on a computer. Just
like you use folders to keep your papers and documents in order, the operating system uses directories to
keep track of files and where they are stored. Different structures of directories can be used to organize these
files, making it easier to find and manage them.
1) Single-Level Directory
The single-level directory is the simplest directory structure. In it, all files are contained in the same
directory which makes it easy to support and understand.
Advantages
1) Since it is a single directory, so its implementation is very easy.
2) If the files are smaller in size, searching will become faster.
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.
Advantages
1) A security would be there which would prevent user to access other user’s
files.
2) Searching of the files becomes very easy in this directory structure.
Tree directory structure of operating system is most commonly used in our personal computers. User can
create files and subdirectories too, which was a disadvantage in the previous directory structures.
Advantages
draw the diagram of linked file allocation methods and explain it-4M
The allocation methods define how the files are stored in the disk blocks.
1) Contiguous Allocation
2) Linked Allocation
3)Indexed Allocation
-In this scheme, each file is a linked list of disk blocks which need not be contiguous. The disk blocks can be
scattered anywhere on the disk.
-The directory entry contains a pointer to the starting and the ending file block. Each block contains a
pointer to the next block occupied by the file.
-The file ‘jeep’ in following image shows how the blocks are randomly distributed. The last block (25)
contains -1 indicating a null pointer and does not point to any other block.
Linked
Advantages:
1) This is very flexible in terms of file size. File size can be increased easily
since the system does not have to look for a contiguous chunk of memory.
2) This method does not suffer from external fragmentation. This makes it
relatively better in terms of memory utilization.
Disadvantages:
3) Because the file blocks are distributed randomly on the disk, a large
number of seeks are needed to access every block individually. This makes
linked allocation slower.
4) It does not support random or direct access. We can not directly access the
blocks of a file.