0% found this document useful (0 votes)
32 views4 pages

Exam Answers

Uploaded by

Meregulwa Allan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views4 pages

Exam Answers

Uploaded by

Meregulwa Allan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

File Allocation Methods

a) Contiguous Allocation (5 marks):

In contiguous allocation, each file occupies a set of consecutive blocks on the disk. This makes

accessing files very fast, as the system can retrieve the entire file in one go, especially during

sequential access. However, it can lead to external fragmentation where free space is scattered in

small blocks across the disk. An example is how early DOS file systems allocated files on a hard

drive.

b) Linked Allocation (5 marks):

Linked allocation links each file's blocks via pointers. Every block contains a pointer to the next block

in the sequence. This method eliminates external fragmentation but introduces overhead, as every

block must store a pointer, and it can be inefficient for random access. A real-world example would

be floppy disk systems using FAT12.

c) Indexed Allocation (5 marks):

Indexed allocation uses an index block to hold pointers to the actual blocks of a file. This makes

random access fast, as the entire index can be used to quickly locate blocks. However, this requires

additional space for the index. An example would be Unix file systems using inode structures for file

management.

---

2. Deadlock
a) Conditions for Deadlock (4 marks):

Deadlock occurs when four conditions are met simultaneously:

- Mutual Exclusion: A resource is non-shareable; only one process can use it at a time.

- Hold and Wait: A process holding a resource is waiting for another resource held by another

process.

- No Preemption: Resources cannot be forcibly removed from the process holding them.

- Circular Wait: A circular chain of processes exists, where each process is waiting for a resource

held by the next process in the chain.

An example of this is two processes trying to access the same printer and a hard drive, each

holding one and waiting for the other.

b) Prevention of Deadlock (4 marks):

To prevent deadlock, at least one of the conditions must be negated. For example:

- Mutual Exclusion: Use sharable resources when possible.

- Hold and Wait: Require processes to request all their resources at once.

- No Preemption: Allow the system to take resources back from a process.

- Circular Wait: Impose a resource ordering rule, forcing processes to request resources in a

particular sequence.

An example is the Banker's Algorithm, which ensures safe resource allocation to avoid deadlocks.

---

3. Memory Management Techniques (10 marks)


a) Fragmentation:

Fragmentation is the inefficient use of memory, with internal fragmentation occurring when memory

allocated to a process is larger than required, and external fragmentation when free memory is

scattered in small, non-contiguous blocks.

b) Multiple-Partition Allocation:

This is where memory is divided into fixed or variable-size partitions, and each partition is allocated

to one process at a time. The main problem with this method is fragmentation.

c) Contiguous Allocation:

Memory is allocated in a continuous block. It is simple to implement and offers fast access, but it

leads to external fragmentation. Memory compaction can be used to solve this problem.

d) Segmentation:

In segmentation, the process is divided into segments of different sizes according to its logical

structure, e.g., code, data, and stack segments. This method allows for easy access but suffers from

external fragmentation.

e) Paging:

Paging divides both physical memory and processes into fixed-size pages. It eliminates external

fragmentation but can introduce page table overhead. Pages are mapped to frames in physical

memory using a page table.

---

4. Differentiation (7 marks)
a) Demand Paging vs Pure Demand Paging (3 marks):

- Demand Paging: Pages are loaded into memory only when they are needed during execution.

- Pure Demand Paging: No pages are loaded until a page fault occurs. This is a more extreme form

of demand paging, where all processes start with zero pages in memory.

b) Page Table vs Segment Table (2 marks):

- Page Table: Maps virtual pages to physical frames in memory. It manages fixed-size pages.

- Segment Table: Maps segments of varying sizes to memory locations, used in segmentation.

c) First-Fit vs Best-Fit Placement (2 marks):

- First-Fit Placement: Allocates the first available block that is large enough for the request.

- Best-Fit Placement: Searches for the smallest free block that fits the request to minimize wasted

space.

You might also like