Week 3 – CST– 334 Operating System

Module 3 – Introduction to Memory Virtualization

This week we learned about Memory Virtualization and how the OS manages memory. The virtual memory system provides the illusion of a large memory address space. This space is accessed by the running program by using virtual addresses.

We also covered the types of memory which include the stack and the heap. Allocations and deallocations to the stack are managed implicitly by the compiler. When you return from a function, the compiler deallocates the memory for you. In order to keep the memory allocated, you have to explicitly allocate it to the heap using malloc(). When you call malloc() successfully, it returns a pointer to the allocated memory space or else it will return NULL. Using malloc requires the programmer to use the free() call to free the heap memory that is no longer in use.

Another topic we covered was address translation. It is the process by which the OS controls memory access by a process and ensures that the access requests stay within the limits of the address space assigned to that process. The OS uses the base and bounds registers to make sure the process cannot generate references outside its address space.

Segmentation solves the problem of all the wasted space between the stack and the heap. Instead of having just one base and bounds pair in the MMU (Memory Management Unit), it allows for a pair of base and bounds per logical segment of the address space.

Lastly, we learned about managing free space. When the memory consists of variable sizes, the free space becomes fragmented into little left over pieces which is called external fragmentation. Eventually, requests for free space might fail because there is no free space that meets or exceeds the amount of contiguous memory requested. The OS uses techniques called splitting and coalescing. In splitting, the allocator finds a free chunk of memory that satisfies the size requested into two. The first chunk will return to the caller and the second will remain on the free list. With coalescing, allocators coalesce free space when a chunk of memory is freed. The allocator looks at the address of the free chunk and if there is another free chunk next to it, it merges the chunks to create a single larger free chunk.

Comments

Popular posts from this blog