3rd Week: CST 334
Hello everyone,
This week in CST 334, we were introduced to Memory Virtualization, which includes topics like Address Space, Memory API, Address Translation, and Segmentation. The concept of address space is important to memory virtualization because it allows the OS to maximize CPU and memory efficiency by partitioning memory and enabling multiple processes to run at the same time. Each process gets its own memory space which allows the OS to map addresses to bytes uniquely for each process. This helps maintaining isolation. Different methods can be used to virtualize memory, such as time sharing, static relocation, and dynamic relocation. Providing each process with its own address space the OS enables memory virtualization and supports multiprogramming where multiple processes can run concurrently.
A process has different types of memory, such as static and dynamic. For dynamic memory, we need the Memory API, which allows us to allocate and deallocate memory as needed. We can use the malloc() function for memory allocation, which requires including the stdlib.h library. We pass malloc() an argument specifying the size of memory needed in bytes and it returns a void pointer to a memory area if the allocation is successful. When we’re finished and no longer need that memory space we should free it. Otherwise, we can end up using all the memory in the heap and potentially causing a memory leak. We can free memory by using the free() function and passing it the pointer to the allocated memory.
Address translation is important for memory virtualization because it converts virtual addresses into physical addresses. This process allows the operating system to keep each program’s memory safe, share memory when needed, and manage flexible memory areas like heaps and stacks. Address translation is designed to be efficient so it can help memory to be placed well and accessed faster. Using limited direct execution (LDE), the hardware handles most address translations, while the operating system steps in only when necessary such as during program switches or errors.
Segmentation divides a program's memory into different parts: code, stack, and heap. Each has its own length and permissions this allows for flexible memory management. Each segment is identified by a segment number and an offset within that segment. This setup helps with efficient memory use and sharing but requires each segment to occupy a continuous memory block.
Comments
Post a Comment