Week 27
CST 334
This is our third week in CST-334, also known as Operating Systems.
Operating Systems: Three Easy Pieces
This week we read chapters 13-17 in our text book.
Chapter 13: Address Spaces
Chapter 13 discusses the virtualization of memory, or address spaces.
Key Takeaways:
- Each process has an address space, an abstraction of where its memory is located in physical memory.
- The goals of virtual memory are transparency, efficiency, and protection.
Chapter 14: Memory API
Chapter 14 discusses the malloc and free functions in the C language.
Key Takeaways:
- The malloc function attempts to allocate memory on the heap. It returns a pointer to the allocated memory on a success, or NULL on a failure.
- The free function takes a pointer returned by malloc, and frees the associated memory.
- Several errors are possible with manual memory management, such as forgetting to allocate memory, not allocating enough memory, forgetting to initialize allocated memory, forgetting to free memory, and freeing memory repeatedly.
Chapter 15: Address Translation
Chapter 15 discusses address translation, or how virtual memory addresses are translated into physical memory addresses.
Key Takeaways:
- Base and bounds registers are used to store where an address space is located on physical memory, and the size of the address space's allocation of physical memory respectively.
- A virtual memory address is converted to a physical memory address by adding the base to it.
- The CPU raises an exception if the converted physical memory address is greater than the bounds (too big), or if the virtual memory address is negative.
- The memory management unit (MMU) is the part of the CPU that handles memory management and translation.
Chapter 16: Segmentation
Chapter 16 discusses segmentation, which is where different parts of a process's address space may be located in different parts of physical memory.
Key Takeaways:
- Separate base and bounds are kept for each segmented portion of memory.
- CPUs split virtual memory addresses into two parts, the segment (the first two bits) and the offset.
- The segment determines if the memory address is in the code, heap, or stack.
- The offset determines where the address is located within the code, heap, or stack.
- Alongside base and bounds, another value tracks whether a portion of memory grows negatively or positively.
- Code sharing allows processes to access each others' memory.
Chapter 17: Free Space Management
Chapter 17 discusses the management of free space in memory.
Key Takeaways:
- External fragmentation is when portions of free memory are fragmented between portions of allocated memory, making it harder to allocate new memory.
- Internal fragmentation is when portions of allocated memory go unused, such as if too much memory was allocated.
- Systems keep a header at the beginning of a piece of allocated memory, which stores certain data, such as the size of the allocated memory.
- A free list, or a list of portions of free memory, is kept by the system.
- Multiple strategies exist for allocating memory:
- Best fit searches through the free list, and returns the smallest chunk of free memory that satisfies the request.
- Worst fit finds and returns the largest chunk of free memory.
- First fit returns the first chunk of free memory that satisfies the request.
- Next fit begins the search where the last search ended.
- Buddy allocation divides portions of memory by powers of two.
Comments
Post a Comment