OS 2023 Solution
OS 2023 Solution
- **Thread:**
- A thread is a lightweight unit of a process that shares the same
resources.
- Threads within a process share the same address space and file
descriptors.
- Threads can communicate more easily, as they share data and
resources directly.
- Less overhead compared to processes.
Q.6 **Define Thrashing. What are the reasons for thrashing?**
**Thrashing** occurs in a computer system when the CPU spends
more time swapping pages between main memory and secondary
storage than actually executing processes. It is usually caused by a
shortage of available memory. Reasons for thrashing include:
- **Insufficient Memory:** When the demand for memory exceeds the
available physical memory.
- **Poor Page Replacement Policies:** Inefficient page replacement
algorithms can contribute to thrashing.
- **High Degree of Multiprogramming:** Running too many processes
simultaneously can lead to increased demand for memory.
Q.8 **What are the various file accessing methods? Define the term
seek time and rotational latency.**
- **File Accessing Methods:**
- **Sequential Access:** Accessing data in a sequential order.
- **Direct Access (Random Access):** Directly accessing any block of
data using an index or key.
- **Seek Time:** The time taken by the disk's read/write head to move
to the specified track.
- **Rotational Latency:** The time it takes for the desired disk sector
to rotate under the disk's read/write head.
Q 9 Define the term seek time and rotational latency.
**Seek Time:**
Seek time is the time it takes for the read/write head of a disk to
position itself over the appropriate track where data is to be read from
or written to. It includes the time required for the disk arm to move the
read/write head to the desired track. Seek time is a critical factor in
overall disk access time, and minimizing it contributes to improving the
performance of disk I/O operations.
**Rotational Latency:**
Rotational latency, also known as rotational delay, is the time it takes
for the desired disk sector to rotate under the disk's read/write head.
Once the read/write head is positioned over the correct track, the disk
must rotate until the desired sector is directly under the head before
data can be read from or written to the disk. Rotational latency is
influenced by the rotational speed of the disk (measured in revolutions
per minute, RPM) and is a significant component of the total disk access
time. Minimizing rotational latency contributes to faster disk I/O
operations.
Q.10 **What is the role of dispatcher?**
The **dispatcher** is a component of the operating system that
controls the switching of the CPU from one process to another. Its
primary role is to manage the execution of processes by making
decisions on process scheduling and context switching. The dispatcher
is responsible for loading the saved context of a process that is ready to
execute and saving the context of the currently running process. It plays
a crucial role in the efficient utilization of the CPU and ensures fair and
timely execution of processes.
PART B
**Q.1 Explain different operations performed by the operating
system.**
The operating system performs various operations to manage
computer resources and provide a user-friendly environment. These
operations include:
1. **Process Management:** Creation, scheduling, and termination of
processes.
2. **Memory Management:** Allocation and deallocation of memory
resources.
3. **File System Management:** Organization, storage, retrieval, and
protection of files and directories.
4. **Device Management:** Managing input and output devices.
5. **Security and Protection:** Ensuring data and resource security
through access control.
6. **User Interface:** Providing a user-friendly interface for
interaction.
7. **Networking:** Managing communication between computers in a
network.
8. **Error Handling:** Detecting and handling errors for system
stability.
9. **Job Scheduling:** Efficiently scheduling tasks for optimal resource
utilization.
**Q.2 Define process. How many different states a process has? Explain
when a process changes the state using a proper diagram.**
- **Process Definition:** A process is an independent program in
execution, with its own memory space and resources.
- **Process States:**
1. **New:** The process is being created.
2. **Ready:** The process is ready to execute but waiting for the CPU.
3. **Running:** The process is actively executing.
4. **Blocked (or Waiting):** The process is waiting for an event to
proceed.
5. **Terminated:** The process has finished execution.
- **Medium-term Scheduling:**
- Swaps processes in and out of main memory.
- Timeframe: Seconds to Minutes.
- Goal: Manage the degree of multiprogramming to optimize system
performance.
**Page Buffering:**
- Page buffering involves keeping a certain number of pages in main
memory even if they are not immediately needed.
- Accomplishments:
- **Improves Response Time:** Frequently accessed pages are
already in memory, reducing the need for frequent page faults.
- **Utilizes Locality:** Takes advantage of the Principle of Locality by
keeping relevant pages in memory.
**Q.7 Explain the architecture of the Linux operating system with a
proper diagram.**
For a detailed explanation of the Linux operating system architecture
with a diagram, please refer to official Linux documentation or specific
resources, as it involves multiple components and layers that are
beyond the scope of a text-based response. You can find detailed
information in Linux system architecture documentation or books on
Linux internals.
ANS 1
Consider the following set of process to be executed, with the arrival time
and CPU burst time given in milliseconds. Calculate average waiting time
and turn-around time using given scheduling algorithm. Draw Gantt chart
for each type.
To calculate the average waiting time and turn-around time for each
scheduling algorithm and draw Gantt charts, we'll go through each
algorithm one by one.
**Process Data:**
```
Process Arrival Time CPU Burst Time
P1 0 5
P2 1 3
P3 2 3
P4 3 1
```
### (i) FCFS (First-Come-First-Serve):
**Gantt Chart:**
```
| P1 | P2 | P3 | P4 |
0 5 8 11 12
```
**Waiting Time:**
- P1: 0 ms
- P2: 5 ms
- P3: 8 ms
- P4: 11 ms
**Turn-Around Time:**
- P1: 5 ms
- P2: 8 ms
- P3: 11 ms
- P4: 12 ms
**Average Waiting Time:** (0 + 5 + 8 + 11) / 4 = 6 ms
**Average Turn-Around Time:** (5 + 8 + 11 + 12) / 4 = 9 ms
**Turn-Around Time:**
- P1: 15 ms
- P2: 4 ms
- P3: 7 ms
- P4: 1 ms
**Turn-Around Time:**
- P1: 11 ms
- P2: 5 ms
- P3: 7 ms
- P4: 4 ms
Please note that waiting time and turn-around time are calculated
using the formulas:
- Waiting Time = Turn-Around Time - Burst Time
- Turn-Around Time = Completion Time - Arrival Time
--------------------------------------------------------------------------
ANS 2
----------------------------------------------------
**FIFO Scheduling:**
- Tracks: 345 → 123 → 874 → 692 → 475 → 105 → 376.
- Total Tracks Moved: 1946.
**SSTF Scheduling:**
- Tracks: 345 → 376 → 475 → 692 → 874 → 105 → 123.
- Total Tracks Moved: 680.
**SCAN Scheduling:**
- Tracks: 345 → 105 → 123 → 376 → 475 → 692 → 874.
- Total Tracks Moved: 1151.
**Q.4 Page Faults:**
- **Page Reference String:** 1, 2, 3, 4, 5, 3, 4, 1, 6, 7, 8, 7, 8, 9, 7, 8, 9,
5, 4, 5, 4, 2.
- **Frames:** 4.
**Short Notes:**