Quiz 4 1. If malloc fails to reserve more memory it returns [NULL] from: https://github.com/angrave/SystemProgramming/wiki/Memory%2C-Part-1%3A-Heap-Memory-Introduction#can-malloc-fail 2. What is the difference between calloc and malloc? Unlike malloc, calloc initializes memory contents to zero and also takes two arguments (the number of items and the size in bytes of each item). from: https://github.com/angrave/SystemProgramming/wiki/Memory%2C-Part-1%3A-Heap-Memory-Introduction#what-is-calloc 3. How could you use sbrk to find the current location of the program break, (or in other words, where the heap ends)? You would call sbrk(0) to get it to tell you where your heap currently ends from:https://github.com/angrave/SystemProgramming/wiki/Memory%2C-Part-1%3A-Heap-Memory-Introduction#do-programs-need-to-call-brk-or-sbrk 4. What is Internal Fragmentation, and why could this become an issue if this isn't addressed? Internal fragmentation happens when the block you give them is larger than their allocation size. You may end up returning a block of size much larger than what you allocated! There is a lot of overhead for that allocation which is what we are trying to avoid. from:https://github.com/angrave/SystemProgramming/wiki/Memory%2C-Part-2%3A-Implementing-a-Memory-Allocator#a-note-about-internal-fragmentation 5. Suppose you tried running a program, and it tells you that there was a "bus error", what does that mean? A bus error is when a process tries to access memory that the CPU cannot physically address from the link to the wiki article on bus error https://en.wikipedia.org/wiki/Bus_error from this section: https://github.com/angrave/SystemProgramming/wiki/Memory%2C-Part-2%3A-Implementing-a-Memory-Allocator#alignment-and-rounding-up-considerations 6. The heap does not have a fixed size (true) 7. The reading describes three different placement strategies for memory allocation. It also mentions that using just malloc, you'd need to use the "worst fit" strategy. Why would that be necessary? As malloc does not know how the user will use the allocated memory (array of doubles? array of chars?), the pointer returned to the program needs to be aligned for the worst case, which is architecture dependent. from: https://github.com/angrave/SystemProgramming/wiki/Memory%2C-Part-2%3A-Implementing-a-Memory-Allocator#alignment-and-rounding-up-considerations