Os Previous Year Question Paper
Os Previous Year Question Paper
Os Previous Year Question Paper
Ans. The critical section problem is to make sure that only one process should be in a critical section
at a time. When a process is in the critical section, no other processes are allowed to enter the
critical section. This solves the race condition.
Mutual Exclusion: This means that when one process is executing within its critical section, no other
process should be allowed to enter its own critical section. This ensures that shared resources are
accessed by only one process at a time, preventing conflicts and data corruption.
Ans. The Dining Philosophers Problem can be solved using synchronization mechanisms like
semaphores or mutex locks. Each philosopher must acquire two adjacent chopsticks to eat and
release them afterward. A mutex ensures exclusive access, allowing only one philosopher at a time to
attempt acquiring chopsticks, preventing conflicts. This solution avoids deadlock, where philosophers
are indefinitely blocked, and ensures mutual exclusion, enabling philosophers to alternate between
thinking and eating without contention over chopstick access.
Ans. Process Control Block is a data structure that contains information of the process related to it.
The process control block is also known as a task control block, entry of the process table, etc.
It is very important for process management as the data structuring for processes is done in terms of
the PCB. It also defines the current state of the operating system.
Process State
Process Number
Program Counter
Register
Memory Limits
.
.
.
.
Process control block(PCB)
(iv). Discuss process state Diagram with suitable Diagram.
Ans. The process state diagram is used to represent the transitions between different states of a
process and is an essential concept in process management in operating systems.
(v).
Ans.
15. Marks question.
(i) Explain Banker’s algorithm: safety Algorithm and Resource Request Algorithm
Ans. The Banker's algorithm is a resource allocation and deadlock avoidance algorithm used in
operating systems. It ensures that processes request and release resources in a safe manner to avoid
deadlock. The algorithm consists of two main parts: the Safety Algorithm and the Resource Request
Algorithm.
Safety Algorithm: The Safety Algorithm checks whether a system is in a safe state before allocating
resources to a process. It simulates resource allocation and deallocation to determine if the system
can satisfy the resource needs of all processes. If a safe sequence is found, resources are allocated;
otherwise, the system waits until resources are available. This ensures that resource allocation will
not lead to a deadlock.
Resource Request Algorithm: When a process requests additional resources, the Resource Request
Algorithm determines if granting the request will leave the system in a safe state. If so, the resources
are allocated; otherwise, the process must wait. This prevents resource allocation that could
potentially lead to deadlock situations.
Ans. Deadlock is a state in a system where two or more processes cannot proceed because each is
waiting for the other to release a resource. The necessary conditions for deadlock are often
summarized using the Coffman Conditions, named after Edward G. Coffman, Jr.
Mutual Exclusion: Only one process can use a resource at any given time i.e. the resources are non-
sharable
Hold and Wait: A process must be holding at least one resource and waiting to acquire additional
resources that are currently held by other processes.
Circular Wait: There must exist a circular waiting chain such that each process in the chain is waiting
for a resource held by the next process in the chain.
Ans. If one of the persons tries editing the file, no other person should be reading or writing at the
same time, otherwise changes will not be visible to him/her.
However, if some person is reading the file, then others may read it at the same time.
Ans. Semaphore in OS is a synchronization tool used to regulate access to shared resources such as
files, memory, or network connections. It is essentially a variable that controls access to the shared
resource.
Binary Semaphore: Also known as a mutex (short for mutual exclusion), a binary semaphore can take
on only two values, typically 0 or 1.
It is used to control access to a shared resource by allowing or denying access to one thread at a
time.
Counting Semaphore: Unlike binary semaphores, counting semaphores can take on a range of non-
negative integer values.
They are useful in scenarios where multiple instances of a resource can be accessed simultaneously,
up to a specified limit.
Ans.
Advantage Disadvantage
Efficient allocation: Semaphores allow for a -Semaphores are prone to programming errors.
more efficient allocation of system resources, -Due to the complexity of semaphore
which means that memory can be used more programming, mutual exclusion may not be
effectively. achieved.
Control over multiple processes: Semaphores -One of the most significant limitations of
give you control over multiple processes, which semaphores is priority inversion. Low priority
means you can allocate memory to specific processes get into a critical section, and high
tasks as needed. priority processes keep waiting.
Increased performance: Semaphore-based -Semaphores can be expensive to implement in
memory management can result in increased terms of memory and CPU usage
performance and improved system
responsiveness.
(vi). Explain MMU translates the logical address to the physical address.
Ans. The Memory Management Unit (MMU) translates virtual addresses to physical addresses,
enforcing memory protection, managing virtual memory, and optimizing performance in a computer
system. The (MMU) translates logical addresses (virtual addresses) generated by the CPU into
physical addresses. It uses a page table to map the page number in the logical address to a frame
number in physical memory, combining it with the offset to generate the physical address. This
translation is crucial for efficient memory management, protection, and the implementation of
virtual memory.
(vii). What is meant by internal fragmentation and External Fragmentation? Describe with suitable
diagram.
Ans.
External fragmentation occurs when free Internal fragmentation occurs when memory is
memory blocks are scattered throughout the allocated in fixed-size blocks, and the allocated
memory space, making it challenging to allocate memory block is larger than the actual space
contiguous memory blocks for new processes, needed by the process. As a result, there is
even though the total free memory might be wasted memory within the allocated block. This
sufficient. It's the fragmentation external to wasted space is internal to the allocated block
allocated memory blocks. and cannot be utilized by other processes.