Computer Science BS Journal (CST334) : Week 3
This week in CST334 our lectures covered: Address Spaces, C Memory API, Address Translation & Base-and-bounds, Segmentation, Free Space Management. We also started working on our first group project this week. In this learning journal I'll write and explanation/what I think to be the most important bits of each subject.
1. Address Spaces
An address space is the range of memory addresses that a process can use. Each process has its own virtual address space, isolated from others, managed by the operating system.
Key Takeaways:
-
Provides process isolation.
-
Helps with security and stability.
-
Enables virtual memory and memory protection.
2. C Memory API
The C memory API includes functions for dynamic memory allocation and deallocation: malloc(), calloc(), realloc(), and free().
Key Takeaways:
-
malloc(size)allocates a block of memory. -
calloc(n, size)allocates and zero-initializes memory. -
realloc(ptr, new_size)resizes previously allocated memory. -
free(ptr)releases memory back to the system. -
Improper memory management can cause leaks, dangling pointers, and crashes.
3. Address Translation & Base-and-Bounds
Address translation maps a program’s virtual address to a physical address in RAM. A simple form is the base-and-bounds model: all addresses used by a process are offset by a base address and must be within a specified bound.
Key Takeaways:
-
Base register holds the starting physical address.
-
Bounds register limits the accessible memory size.
-
Protects against memory access violations.
-
Simple but limited – doesn't support complex memory layouts.
4. Segmentation
Segmentation divides a process’s address space into logical segments like code, stack, heap, etc. Each segment has its own base and bound.
Key Takeaways:
-
Segments provide logical organization of memory.
-
Allows variable-sized memory blocks.
-
Enables fine-grained protection.
-
Can suffer from external fragmentation.
5. Free Space Management
Refers to how memory allocators manage unallocated (free) memory. Strategies include free lists, bitmaps, and algorithms like first fit, best fit, and worst fit.
Key Takeaways:
-
Efficient free space management is crucial for performance.
-
Poor strategy can lead to fragmentation (internal & external).
-
Common methods:
-
First fit: finds first block large enough.
-
Best fit: finds smallest block that fits.
-
Worst fit: uses largest available block.
Comments
Post a Comment