Sunday, July 13, 2025

CST334: Week 3 (Week 27)

 This week we spent time looking at memory and some of the challenges and solutions to maintaining performance and safety on systems that need to multi-task with limited resources. We learned how process address spaces are defined, how address space separation is maintained, how multiple processes can co-exist in memory, and how the memory hierarchy can be used to maximize resource sharing for many processes with finite system resources.

We learned about virtual memory and address translation which is very important to how modern general purpose operating systems function. A system has a finite amount of RAM/memory but has many processes active at the same time. To maintain the illusion that each process has all of its resources available in memory, virtual addresses and address translation are used to employ different layers of the memory hierarchy. Whereas it appears to a process that all of its resources exist in RAM, they may actually map to flash memory, for example. Virtual addresses, bases, bounds, and offsets are what enable this approach. Highlighting the benefit of having an MMU was important since it explains how address translations can be executed quickly in hardware, how an extra layer of security is enforced, and why Linux, Windows, and MacOS can be run on an ARM Cortex-A, but not on an ARM Cortex-M.

We learned how process memory is broken down into segments - code, stack, and heap. The clear benefit here is that a process doesn't require a single contiguous block of memory to run. This would be prohibitive. Instead, smaller portions can be allocated and distributed on the memory hierarchy using virtual memory. 

We learned about different memory allocation schemes and their trade-offs. Best fit, first fit, worst fit, etc. Some approaches are better at avoiding fragmentation, some are faster, some are less likely to result in failed allocations. There is no perfect scheme in most cases since in any non-trivial application, it isn't possible to predict how much memory will be requested. I was able to look at the Linux kernel's approach to memory allocation and learned that those simple approaches are still an important part of how deployed, production OSes manage free memory.

No comments:

Post a Comment

CST370: Week 7 (Week 58)

 This week we covered non-comparison sorting, dynamic programming, Warshall's algorithm, Floyd's algorithm, Greedy Technique, and Pr...