OS Assignment 1&2 Solution
OS Assignment 1&2 Solution
3. What is Kernel?
Ans. The kernel is the core component of an operating system that manages hardware resources,
scheduling processes, and low-level system functions.
10. What is Critical Region? How do they relate to controlling access to shared resources?
Ans. A critical region is a code section where shared resources are accessed. They relate to controlling
access by using synchronization techniques to prevent conflicts.
15. What do you mean by Semaphores? Explain the types of Semaphores with example.
Ans. Semaphores are synchronization tools used in concurrent programming to control access to
shared resources. Two types are Binary Semaphores (0 or 1, used for mutex) and Counting Semaphores
(allow multiple resource access). For example, a binary semaphore can protect access to a critical
section, ensuring only one thread enters at a time.
16. What is the purpose of a TLB? Explain the TLB lookup with the help of a block diagram, explaining the
hardware required.
Ans. The Translation Lookaside Buffer (TLB) is a hardware cache that stores frequently used virtual-
tophysical memory address translations. It speeds up memory access by reducing the need to access
the page table. TLB lookup involves comparing the virtual page number from the CPU's memory
request with entries in the TLB, returning the corresponding physical page if found.
17. What is meant by virtual memory? With the help of a block diagram explain the data structures used.
Ans. Virtual memory is a memory management technique that uses a combination of RAM and disk
space to provide the illusion of a larger memory space than physically available. Data structures like
page tables are used to map virtual addresses to physical addresses, allowing efficient memory
management.
18. What do you understand by paging? Why there is need of multilevel paging?
Ans. Paging divides memory into fixed-size pages for efficient allocation. Multilevel paging adds an
additional level of page tables to reduce the memory overhead associated with large address spaces,
making memory management more efficient.
29. Draw Process State Transition Diagram and explain each state in detail.
Ans. A Process State Transition Diagram typically includes states like: - New: The process is being
created. - Ready: The process is ready to execute but waiting for CPU time. - Running: The process is
currently executing on the CPU. - Blocked/Waiting: The process is waiting for an event or resource. -
Terminated: The process has completed execution. These states represent the life cycle of a process,
and transitions occur as the process moves through different phases of execution.
30. What is a page and what is a frame? How are the two related?
Ans. A page is a fixed-size unit of virtual memory, while a frame is a corresponding fixed-size unit in
physical memory (RAM). The two are related through a page table, which maps virtual pages to
physical frames. When a process accesses a page, the page table resolves its physical location, allowing
data to be read from or written to the associated frame. This mapping enables efficient memory
management, as pages can be dynamically loaded from secondary storage into available frames as
needed.
33. Explain all terms used in PCB. Write a short note on PCB
Ans. . A Process Control Block (PCB) is a data structure used by the operating system to manage and
store information about each process. Key terms in a PCB include: - Process ID - Program Counter - CPU
registers - Process state - Priority - Memory management information - I/O information - CPU
scheduling information - Pointer to the next PCB PCBs play a crucial role in process management and
scheduling within an operating system.
34. Consider the following five jobs assumed to be arrived at same time
JOB BURST TIME (in min.) PRIORITY
A 14 5
B 8 1
C 2 6
D 6 9
E 10 4
Here lower integer value corresponding to higher priority. Calculate the average turn-around time and
average waiting time for following scheduling algorithms.
a) Round-Robin (Time Quantum=1min), b) FCFS, c) SJF, d) Priority scheduling.
Ans. .To calculate the average turnaround time and average waiting time for the given jobs using
different scheduling algorithms, we'll apply each algorithm step by step.
Given jobs:
- A with burst time 14 and priority 5
- B with burst time 8 and priority 1
- C with burst time 2 and priority 6
- D with burst time 6 and priority 9
- E with burst time 10 and priority 4
5. Waiting time for each job: - Waiting time (A) = Turnaround time (A) - Burst time (A) = 14 - 14
=0
- Waiting time (B) = 32 - 8 = 24
- Waiting time (C) = 15 - 2 = 13
- Waiting time (D) = 43 - 6 = 37
- Waiting time (E) = 33 - 10 = 23
b) FCFS (First-Come-First-Served):
d) Priority Scheduling:
1. Priority execution order: B, E, A, C, D
2. Calculate turnaround time and waiting time:
- Turnaround time (B) = 8
- Turnaround time (E) = 18
- Turnaround time (A) = 32
- Turnaround time (C) = 35
- Turnaround time (D) = 44
In summary: -
Round-Robin: Average Turnaround Time = 27.4 minutes, Average Waiting Time = 19.4 minutes
- FCFS: Average Turnaround Time = 26 minutes, Average Waiting Time = 18 minutes
- SJF: Average Turnaround Time = 18.8 minutes, Average Waiting Time = 10.8 minutes
- Priority Scheduling: Average Turnaround Time = 27.4 minutes, Average Waiting Time = 18.8
minutes
35. Explain all terms used in inter-process communication? Using these terms explain
(a) Producer –Consumer Problem (b) Sleeping Barber Problem
Ans. Inter-Process Communication (IPC) is essential for processes to interact and synchronize in multi-
process or multi-threaded environments. Key IPC terms include shared memory, message passing,
semaphores, mutexes, condition variables, and deadlock.
For example, in the Producer-Consumer Problem, shared memory is used as a buffer, protected by
mutexes, and controlled by semaphores to manage access. Producers add items, and consumers
remove them, ensuring proper synchronization.
In the Sleeping Barber Problem, mutexes safeguard access to the barber chair and waiting room, while
semaphores manage customer and chair availability. Customers check chair status and either wait or
leave, and the barber serves one customer at a time. IPC mechanisms like semaphores and mutexes
play critical roles in solving these classic IPC problems.