Professional Documents
Culture Documents
Swapping Paging
• Device Management: The operating system keeps track of all the devices. So, it is also
called the Input/Output controller that decides which process gets the device, when,
and for how much time.
• File Management: It allocates and de-allocates the resources and also decides who
gets the resource.
• Job Accounting: It keeps track of time and resources used by various jobs or users.
• Error-detecting Aids: These contain methods that include the production of dumps,
traces, error messages, and other debugging and error-detecting methods.
• Memory Management: It keeps track of the primary memory, like what part of it is in
use by whom, or what part is not in use, etc. and It also allocates the memory when a
process or program requests it.
• Processor Management: It allocates the processor to a process and then de-allocates
the processor when it is no longer required or the job is done.
• Control on System Performance: It records the delays between the request for a
service and the system.
• Security: It prevents unauthorized access to programs and data using passwords or
some kind of protection technique.
• Convenience: An OS makes a computer more convenient to use.
• Efficiency: An OS allows the computer system resources to be used efficiently.
• Ability to Evolve: An OS should be constructed in such a way as to permit the effective
development, testing, and introduction of new system functions at the same time
without interfering with service.
• Throughput: An OS should be constructed so that It can give maximum
throughput (Number of tasks per unit time).
Answer:
A pager is a memory management technique that divides a
process's virtual memory into pages and allocates them to
physical memory as needed. This allows the process to be larger
than the amount of physical memory available.
A swapper is a memory management technique that moves
entire processes between physical memory and secondary
storage (such as a hard disk). This allows the operating system
to run more processes than would fit in physical memory at once.
The main difference between a pager and a swapper is that a
pager deals with individual pages of a process, while a swapper
deals with entire processes.
Here is a table that summarizes the key differences between
paging and swapping:
Feature Paging Swapping
Faster than
Speed Slower than paging
swapping
The process state diagram represents the various states a process can
be in during its lifecycle. The typical states are:
Example:
Consider three processes (P1, P2, P3) and three resource types (A, B,
C). If P1 holds resource A and requests resource B, P2 holds resource B
and requests resource C, and P3 holds resource C and requests
resource A, a circular wait occurs, leading to an unsafe state.
Q.3
(a) **Inter-process Communication (IPC):**
IPC involves mechanisms that allow processes to communicate and
synchronize with each other. Common IPC mechanisms include
message passing, shared memory, and semaphores.
------------------------------------------------------------------------------------------
Q.5
**File Management:**
**File Structures:**
- **Heap (Unordered) File:** Records are stored in no particular order.
- **Sequential File:** Records are stored in order based on a key field.
- **Hashed File:** A hash function is used to determine the storage
location of each record.
- **Clustered File:** Records with similar values are grouped together.
------------------------------------------------------------------------------
QUE 6
**Difference between Windows and Linux:**
2. **User Interface:**
- **Windows:** Typically has a graphical user interface (GUI) with
the Windows Desktop environment.
- **Linux:** Can have various desktop environments (e.g., GNOME,
KDE) and can also be operated through a command-line interface (CLI).
3. **File System:**
- **Windows:** Primarily uses file systems like NTFS and FAT.
- **Linux:** Supports various file systems, including ext4, Btrfs, and
XFS.
4. **Security Model:**
- **Windows:** Has a different security model with User Account
Control (UAC) and antivirus software often used.
- **Linux:** Follows a robust security model with user privileges and
permissions, and it is less susceptible to malware.
5. **Cost:**
- **Windows:** Typically requires a license fee for each installation.
- **Linux:** Generally free to use and distribute.
7. **Software Installation:**
- **Windows:** Software installation often involves executable (.exe)
files.
- **Linux:** Software is often installed through package managers,
which handle dependencies and updates.
8. **System Customization:**
- **Windows:** Customization options are somewhat limited
compared to Linux.
- **Linux:** Highly customizable, allowing users to modify the kernel
and other components.
1. **Best Fit:**
- Allocates the smallest free block of memory that is large enough to
accommodate the requested size.
- Pros: Reduces fragmentation.
- Cons: May lead to small, unused memory gaps.
2. **Worst Fit:**
- Allocates the largest free block of memory available.
- Pros: Reduces the likelihood of having large unused memory blocks.
- Cons: Can result in increased fragmentation.
3. **Quick Fit:**
- Uses pre-defined block sizes for allocation.
- Allocates the block that is closest in size to the requested size.
- Pros: Reduces search time for a suitable block.
- Cons: May lead to fragmentation if block sizes are not chosen
carefully.
1. **FIFO (First-In-First-Out):**
- Initially, the frames are empty: [ ], [ ], [ ].
- Page 1 comes in: [1], [ ], [ ] (Page Fault: 1).
- Page 2 comes in: [1, 2], [ ], [ ] (Page Fault: 2).
- Page 3 comes in: [1, 2, 3], [ ], [ ] (Page Fault: 3).
- Page 4 comes in: [2, 3, 4], [ ], [ ] (Page Fault: 4).
- Page 1 comes in: [3, 4, 1], [ ], [ ] (Page Fault: 1).
- ... and so on.
Repeat the process for both FIFO and LRU with a frame size of 4.
**Belady's Anomaly:**
**Schedulers:**
3. **Medium-Term Scheduler:**
- Acts as an intermediate between the long-term and short-term
schedulers.
- Responsible for swapping processes in and out of the main
memory.
- Helps in avoiding overloading the memory by moving some
processes to the secondary storage (e.g., swapping to disk).
(b)
**Layered Approach of the Operating System:**
Ans 3
To find the average waiting time and turnaround time using Gantt
chart for Shortest Job First (SJF) and Priority Scheduling, we'll follow
these steps:
**Process Data:**
- Waiting Time:
- P1: 0 ms
- P2: 3 ms
- P3: 11 ms
- P4: 6 ms
- P5: 2 ms
- Turnaround Time:
- P1: 5 ms
- P2: 6 ms
- P3: 19 ms
- P4: 8 ms
- P5: 3 ms
| Time | P4 | P3 | P5 | P2 | P1 |
|-------|----|----|----|----|----|
| Start | 0 | 2 | 3 | 6 | 9 |
| End | 2 | 11 | 4 | 9 | 14 |
- Waiting Time:
- P1: 4 ms
- P2: 6 ms
- P3: 11 ms
- P4: 2 ms
- P5: 3 ms
- Turnaround Time:
- P1: 9 ms
- P2: 9 ms
- P3: 19 ms
- P4: 8 ms
- P5: 4 ms
Ans 4 Suppose a disk drive has 200 cylinders. The drive is initially at cylinder position 98. The queue with request
from I/O to blocks on cylinders - 86, 147, 91, 177, 94, 150, 102, 175, 130 What is the total head movement needed to
satisfy the request for SCAN and C-SCAN scheduling algorithm?
Given the initial position of the disk drive at cylinder 98 and the queue
of requests:
**Calculations:**
- For SCAN and C-SCAN, calculate the distance between each adjacent
pair of requests and sum them up to get the total head movement.
**Segmentation:**
(b) **Segmentation:**
- Segmentation is a memory management technique where memory is
divided into variable-sized segments. Each segment corresponds to a
logical unit, such as a procedure, function, or data structure.
**File Security:**