Operating System: Question Set – 23
What are the main types of memory in a computer system?
- Primary Memory: RAM, used for active processes.
- Secondary Memory: Hard drives and SSDs, used for storage.
- Cache Memory: High-speed memory between CPU and RAM.
- Virtual Memory: Simulated memory using disk space.
- ROM: Read-Only Memory for permanent instructions
What is the difference between static and dynamic memory allocation?
- Static Allocation: Memory size is fixed during program compilation.
- Dynamic Allocation: Memory is allocated during runtime, allowing flexible usage.
Explain the concept of a memory hierarchy.
The memory hierarchy is an organization of memory types by speed and cost:
- Registers: Fastest but smallest.
- Cache: Faster than RAM.
- Main Memory (RAM): Moderate speed.
- Secondary Storage: Slower but larger and cheaper.
What are common page replacement algorithms?
- FIFO (First-In-First-Out): Removes the oldest page.
- LRU (Least Recently Used): Removes the least accessed page.
- Optimal: Removes the page not used for the longest time in the future.
- Clock Algorithm (Second Chance): Gives a second chance to pages with a reference bit set.
What is the purpose of memory protection?
Memory protection makes sure that no process can access or change the memory of another process. It guards against security flaws, crashes, and corrupted data.
How does the OS handle memory allocation?
- Contiguous Allocation: Allocates continuous blocks of memory (prone to fragmentation).
- Non-Contiguous Allocation: Uses paging or segmentation to allocate memory in chunks.
- Dynamic Allocation: Allocates memory as needed during runtime.
What is a TLB (Translation Lookaside Buffer)?
Recently used page table entries are stored in the MMU’s TLB, a high-speed cache. In paging systems, it accelerates address translation.
What are the different memory allocation strategies?
- First-Fit: Allocates the first free block large enough for the process.
- Best-Fit: Allocates the smallest available block that fits.
- Worst-Fit: Allocates the largest available block.
What is slab allocation?
One memory management strategy for kernel memory is slab allocation. It lowers allocation overhead by pre-allocating memory chunks (slabs) of predetermined sizes.
What is the difference between hard and soft page faults?
- Hard Page Fault: The requested page is not in memory and must be loaded from disk.
- Soft Page Fault: The page is not in the current process’s working set but is already in memory.
What is demand paging?
Only when pages are visited does demand paging load them into memory. For large programs, it enhances performance and reduces memory usage.
What is the difference between stack and heap memory?
- Stack Memory: Allocates memory for function calls and local variables. It is automatically managed.
- Heap Memory: Dynamically allocates memory for objects or variables. It is managed manually by the programmer.