DMA and Page Size

Question

How will changing the page size affect the performance of the system with respect to DMA transfers

  1. Efficiency of Data Transfer:
    • Larger Page Size: Increasing the page size allows DMA to move larger blocks of data per operation, reducing the overhead related to initiating and concluding each transfer.
    • Smaller Page Size: Smaller pages increase the management overhead for the same amount of data, as more pages need to be handled, reducing efficiency for large data transfers.
  2. Memory Utilization:
    • Larger pages can lead to more memory wastage (internal fragmentation), especially if the sizes of the data chunks do not align with page boundaries.
    • Smaller pages may reduce wasted space but require more complex management, potentially increasing the handling complexity for DMA operations.
  3. DMA and Memory Management:
    • The alignment of memory blocks with page boundaries is crucial for efficient DMA transfers. Misalignments can complicate handling partial page transfers.
    • Adjusting page sizes affects DMA controller and Memory Management Unit (MMU) interactions, where larger pages might simplify page table management but increase the risk of cache misses.
  4. Impact on Caching:
    • Larger pages might enhance cache efficiency if data utilization is high but can cause cache pollution if not. Smaller pages keep cache content more relevant but may increase cache miss rates due to frequent page replacements.

Memory Size

Question

Imagine a system with a 10-bit, byte-addressable physical address space.

How many bytes of memory will there be?

Each possibility represents a byte, therefore 2

Multi-Layer Page Table

Question

In the worst case, what happens to memory access latency in a virtual addressing environment with a two-level page table, with respect to physical addressing?

Worst case scenario as we are operating on a 2 layer page table, we have no caching at all, and therefore our process will be:

  • First Access - Translate virtual to physical address, access the page directory to find the page table from the relevant entry
  • Second Access - Access the second level page table to retrieve the frame number
  • Third Access - Access the actual data in physical memory using the frame number and offset just found

Given a address in physical addressing, it takes only one memory access to retrieve the data. Virtual Addressing in this case takes 3 accesses in addition to the overhead of translating addresses.

Filesystem Types

Question

Compare and contrast the FAT and EXT2 filesystems. What are the relative advantages and disadvantages of each system.

File Allocation Table (FAT) and Extended Filesystem 2 (EXT2).

FAT is a much simpler filesystem that can be used over multiple platforms. But the added complexity in EXT2 makes it more robust and well suited to more sophisticated file management with larger storage capacities, such as Linux desktops

FAT is universally supported, however EXT2 is typically only supported on Linux

EXT2 has a smaller overhead than FAT, and is therefore more suited to larger systems

FAT is much more prone to fragmentation than EXT2

FAT has a max file size that is much more limited than EXT2

EXT2 supports a large variety of block sizes and inode structures

Virtualization

Question

What is virtualization, in the context of an operating system? [2]

Give three examples of virtualization in OS implementations. [3]

Virtualization is an abstraction mechanism that allows virtual machines, essentially simulated machines, that can run their own operating systems with access to the resources of the host machine, or a subset of the resources.

Memory Virtualization - Using virtual addresses instead of physical addresses, to abstract the complexity of device specific differences in code.

Hardware Virtualization- The OS present a virtualized view of the underlying hardware to higher level applications to enable cross-platform/heterogenous application execution.

Conatinerizatrion

Page Size

Pasted image 20240501053624.png|300]]

Our address size (2^32) is equal to page number + page size, given our page size is 4KB, this is therefore 2^12, meaning our page number is 2^20, and given each page is 4 bytes that gives us a total storage of 2^22, which is 4MB

Total entries for 2 page would be (size inner * amount inner) + (size outer * amount outer) = 2^10 * 2 + 2^10 * 4 = 6144

Polling

Polling for an I/O operation can waste many CPU cycles. However if the I/O device is nearly always ready for service, polling can be much more efficient than catching/dispatching interrupts. Design a hybrid strategy that combines polling, sleeping and interrupts for I/O device management. [ 5 marks ]

For each of the following strategies (a) pure polling, (b) pure interrupts (c) hybrid polling and interrupts as designed in Q1, briefly describe a computing scenario in which that strategy is the most effective. [6 marks]

a) Real Time Systems with a constant input, such as a program running for a hardware sensor

b) A file server, with infrequent requests from the network. It could be efficient to constantly poll the network when you can go hours or days without

Round Robin

Consider a variant of the Round Robin scheduling algorithm in which the entries in the process scheduling queues are pointers to the process control blocks.

(a) what would be the effect of putting two pointers to the same process in the ready queue? [2 marks]

(b) discuss the relative advantages and disadvantages of this scheme. [4 marks]

(c) how could you modify the basic Round Robin algorithm to achieve the same effect, without duplicate pointers? [3 marks]

LRU

+-----+---+---+---+---+---+---+---+---+---+---+---+---+
|  #  | 1 | 3 | 2 | 4 | 2 | 3 | 1 | 4 | 2 | 4 | 1 | 3 |
+-----+---+---+---+---+---+---+---+---+---+---+---+---+
| F-1 | 1 | 1 | 1 | 4 | 4 | 4 | 1 | 1 | 1 | 1 | 1 | 1 |
| F-2 |   | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 2 | 2 | 2 | 3 |
| F-3 |       | 2 | 2 | 2 | 2 | 2 | 4 | 4 | 4 | 4 | 4 |
+-----+---+---+---+---+---+---+---+---+---+---+---+---+
| H/F | F | F | F | F | H | H | F | F | F | H | H | F |
+-----+---+---+---+---+---+---+---+---+---+---+---+---+

Consider the following sequence of virtual memory page references:

1,2,3,4,2,1,5,6,2,1,1,2,7,6,3,2,1,2,3,6

How many page faults would occur, using the LRU replacement algorithm, if the physical memory has

(a) 1 frame [1 mark]

(b) 7 frames [1 mark]

(c) 3 frames [3 marks]

a) 1, 1 F 2, 2 F 3, 3 F 4, 4 F
2, 2 F 1, 1 f 5, 5 F 6, 6 F 2, 2 F 1, 1 F 1, 1 H 2, 2 F 7,7f 6,f 3,f 2,f 1,f 2,f 3,f 6f 19 faults

b) 1, 1 F 2, 1,2 F 3, 1,2,3 F 4, 1,2,3,4 F 2, H 1, H 5, 1,2,3,4,5 F 6, 1,2,3,4,5,6 F 2, H 1, H 1, H 2, H 7, 1,2,3,4,5,6,7 F 6, H 3, H 2, h 1, h 2, h 3, h 6 h

7 faults

c) 1, 1 F 2, 1 2 3, 1 2 3 4, 4 2 3 2, H 1, 4 2 1 5, 5 2 1 6, 5 6 1 2, 5 6 2 1, 1 6 2 1, H 2, H 7, 1 7 2 6, 6 7 2 3, 6 7 3 2, 6 2 3 1, 1 2 3 2, H 3, H 6 F

15 Faults

Random Algo

5  7  8  1  0  7  8  0  4  0  4  5

Given 4 frames whats the min faults For the following seq: 1,3,4,3,2,1,2,4,1

1 4 7 8 1, H 3, F, 1 4 3 8 4, H 3, H 2, F 1 4 3 2 1, H 2, H 4, H 1 F