Tuesday, December 2, 2025

Week 28

This week’s focus on concurrency and threads felt like a big shift from everything we have done so far. Until now, processes always felt simple in the sense that one thing runs at a time, and if something is blocked, that’s it. But the moment we started talking about threads and shared memory, things suddenly became a lot more unpredictable and honestly more interesting. A lot of it clicked while listening to the examples about web browsers loading images in the background while still letting the page respond to scrolling. That helped me visualize why threads matter beyond just “speed.”

What stood out to me the most was the idea that threads share the same virtual memory. At first it sounded convenient, but once we got into critical sections and race conditions, it became clear why this can be dangerous. Seeing how a simple “counter++” can break because of interleaving instructions made me realize how many assumptions I usually make about code running in a neat order. This was one of those moments where I stopped and thought, “Wow, this really does explain why debugging concurrency is such a pain.” The hardest part for me this week was keeping straight when something was thread-safe and when it wasn’t. Mutexes make sense in theory, but the challenge is spotting exactly where they need to be. The lectures did a good job showing how wrapping everything in a lock is not always the best solution either, especially when performance starts to drop as more threads wait on each other. I get the basic mechanics of pthread_create and pthread_join, but I’m still trying to build intuition about when to use locks and when to restructure the code itself. One “aha” moment was understanding why libraries hide these details. Seeing how a thread-safe counter can be wrapped into a small API so the user never touches locks made it clear why real-world systems are designed this way. It connects back to earlier topics about abstraction and virtual memory: hide the complexity so the user doesn’t break things. I’m curious about where this goes next. My guess is we’ll start mixing these thread concepts with scheduling or maybe condition variables. I also wonder how this ties into security issues.

No comments:

Post a Comment

Week 28

This week’s focus on concurrency and threads felt like a big shift from everything we have done so far. Until now, processes always felt sim...