CST 334 - Week 3
This week was about memory management, which, honestly, was hard to understand. I had some ideas about how it works from when I learned programming and also in the architecture course, but that was some time ago. Now, after reading it again, it’s more confusing than helpful. However, what I understand about how memory works is that it’s used to store data, code, instructions, and more. The main memory is one type of memory that allows fast data processing, but it has a limited size and is cleared when it's no longer needed. The purpose of memory management is to allocate the required memory for each program to run and also to protect the memory of other processes while this happens.
For programs, memory is stored in locations to be read and to hold variables and arguments. In some programming languages, memory allocation is done automatically, but in others like C, you can manually allocate memory and also free it when it's no longer necessary. According to the book, allocation is easy, but freeing memory is the difficult part. For me, the allocation method is easy, but I still need to practice when to use it and when it’s not required. Additionally, a mechanism to protect the OS and processes is the separation of memory addresses using registers, if I remember correctly.
Something new I learned is that to create portions for new processes, there are certain allocation algorithms. Some of them are: First Fit, which finds the first hole where the program can fit and is considered the fastest; Best Fit, which allocates the smallest space that fits the program but is considered a poor algorithm; and Worst Fit, which chooses the largest space, leaving remaining space. This last one is often chosen by system designers.
Comments
Post a Comment