CST 334 - Week 3 - TCP/IP makes a lot more sense now

 

  1. Topics we covered in class 
    • Virtual memory
    • Byte-addressable memory
    • Pointers
    • Address space - each process should have its own address space
    • Compiled code uses virtual addresses
    • Memory management unit
    • Dynamically allocated memory
    • Malloc - memory allocate
    • Free - release memory
    • Memory leak
    • Garbage collection
    • Base and bounds
    • Address translation
    • Internal fragmentation
    • External fragmentation
    • Segmentation-break up virtual space instead of having contiguous bits
    • Paging Page frame
    • Virtual page number - VPN
    • Physical frame number - PFN
    • Offset Page
    •  mapping
    • MMU - first fit, worst fit, best fit
  2. Explanation of each topic
    • Virtual memory - Virtual memory lets a computer seem like it has more memory than it actually does. Each process gets its own large, continuous address space. Behind the scenes, only some parts of each process are actually loaded in RAM at a time. The OS uses paging or segmentation to move data between RAM and disk, allowing many processes to run at once even with limited physical memory.
    • Byte-addressable memory - In a byte-addressable system, every single byte has its own address. This lets programs access memory very precisely.
    • Pointers - Pointers store memory addresses instead of regular values. A pointer points to some other location in memory. This allows programs to dynamically access data.
    • Address space - An address space is the complete range of memory addresses a process can use. Each process has its own private address space, which makes processes isolated and safe. One process cannot read or modify another’s memory. When a program is compiled, its instructions reference virtual addresses, because the compiler does not know where the process will actually be loaded in physical RAM. The OS and CPU use address translation to map these virtual addresses to physical ones at runtime.
    • Memory management unit - The MMU is a hardware component that translates every virtual address generated by the CPU into the correct physical address in RAM. It also enforces protection bits (read/write/execute), detects invalid accesses, and works with page tables to manage paging.
    • Dynamically allocated memory - This is memory that is created while the program is running, not at compile time.
    • Malloc (memory allocate) -  malloc() is a C function that reserves a block of memory from the heap. 
    • Free (release memory) - The free() function returns memory previously allocated by malloc() back to the system. Not calling free() is what eventually causes memory leaks.
    • Memory leak - A memory leak happens when a program allocates memory but fails to free it. Over time, the heap grows, available memory shrinks, and the program or system may slow down or crash. Leaks are common when pointers get overwritten or lost.
    • Garbage collection - Garbage collection is an automatic system that scans memory for objects that are no longer reachable by the program. These unreachable objects are automatically freed, so the programmer does not need to manually manage memory. Commonly used in languages like Java.
    • Base and bounds - Base registers stores the physical address where a process’s memory starts while Bounds registers stores how large that memory region is. Any access outside this range triggers an exception, protecting other processes and the OS from corruption.
    • Address translation - The process of converting a virtual address to a physical address. This is done by the MMU using page tables or segment tables. Address translation keeps processes isolated and allows the OS to place pages anywhere in RAM.
    • Internal fragmentation - Wasted memory inside an allocated block.
    • External fragmentation - Occurs when free memory is broken into many small pieces scattered throughout RAM. Even if total free memory is large, none of the pieces may be contiguous enough to satisfy a new request.
    • Segmentation - Segmentation divides virtual memory into variable-sized segments. Each segment can grow independently. This system matches how programs are logically organized.
    • Paging - Paging divides virtual memory and physical memory into equal-sized blocks. This eliminates external fragmentation and allows pages to be placed anywhere in RAM. Page tables map virtual pages to physical frames.
    • Page frame - A page frame is a fixed-size block of physical memory that holds the contents of a virtual page. Frames and pages are the same size.
    • Virtual page number (VPN) - The part of the virtual address that identifies which virtual page the address refers to. The page table uses the VPN to look up the correct frame in RAM.
    • Physical frame number (PFN) - The index of the physical frame in RAM where the virtual page is stored. The MMU uses the PFN plus the offset to form the final physical address.
    • Offset - This is the exact position within a page. The offset is not changed during translation because all pages and frames are the same size.
    •  Page mapping - This is the relationship between a virtual page and the physical frame it resides in. Stored in the page table, these mappings allow the OS to quickly find where data is stored in RAM.
    • MMU (first fit, worst fit, best fit) - These algorithms are used when allocating memory
      1. First Fit - Find the first free block that is large enough.
      2. Best Fit - Find the free block that is closest in size to the requested amount.
      3. Worst Fit - Choose the largest available block.
  3. Identify least-understood topics -- of these topics, which was the hardest for you to write the descriptions?
    • The least understood topic for me was C. The bounds and bases and the virtual addresses vs physical addresses were not easy to grasp but I was able to understand rather quickly. C makes me question my programming skills.
  4. Explain the nature of your confusion -- for these difficult topics, what pieces of them make sense and what pieces are difficult to describe?
    • My confusion mainly came from how C handles memory. I understood virtual memory, base and bounds, and address translation, but actually applying them in C was harder. C won’t stop you from accessing the wrong memory address. I kept questioning whether I was handling the memory addresses correctly. I went back to my handy dandy pseudocode and did more research to make sure I was doing exactly what I wanted to do.
  5. Identify "aha" moments -- which topic did you find it easiest to write about, and why did it make sense?
    • I forget that C really will do exactly what you tell it to without any extra interpretation, so my aha moments came from doing a little bit of research into C to see how to best code for the assignment this week. I am so used to Java, and they assume a lot for you already whereas C does not, but I am gaining a very large appreciation for C. I think this is definitely a fun language to code in.  
  6. Ask questions -- what do you think will come next? Are there any gaps that don't seem to be explained yet?
    • I am very curious as to why we skipped chapter 17 this week, but it is included in next week’s modules. I figure there is a reason for this because it would seem that chapter 17 focuses on managing free space while the other built on top of each other to efficiently use virtual address spaces to ease the burden on physical memory. These methods did have problems with internal and external fragmentation so I think that is what we will cover next.
  7. What connections did you see to other classes and applications -- have you used/heard/thought about these topics before?
    • I have heard a lot about virtual addresses and physical memory. I learned about something similar in IT classes. I knew what paging was, but I never understood how it worked. The concepts of paging and segmentation remind me of how data is transferred with TCP/IP. The lessons this week remind me of a lot of those protocols.

Comments

Popular Posts