CST334 - Week 5 Reflection

 Weekly Learning Reflection

        This week marked a deep dive into concurrency, parallelism, thread scheduling, critical sections, race conditions, how threads interact with shared memory, and why synchronization is vital in multithreaded programs. One immediate concept that stuck out to me was the dichotomy between concurrency and parallelism. Concurrency and a single CPU handling different processes made sense to me and now I see the power and complexity of parallelism--while concurrency relies on time-sharing/context switching, parallelism executes threads simultaneously across multiple CPU cores. While threads share the same address space, program code, global variables, and heap, each thread actually has its own stack to maintain separate execution states. This allows the threads to run independently while avoiding each other's function calls and local variables. Through utilizing distinct stacks, threads can be created and switched between each other more quickly.

        A concurrency concept that we also drilled down into was locking and why it is so crucial. Locks are a synchronization primitive used to control shared resources in a multithreaded environment. Without locks, two threads could update the same variable at the same time and cause data corruption or a crash. Spin locks continuously loop waiting for a lock while ticket locks enforce fairness with a FIFO system. Ticket locks reduce starvation and are more scalable/predictable than spin locks. Mutual exclusion locks, or mutexes, are safer for protecting shared resources. Mutexes allow threads to wait for specific conditions before resuming. A lot of moving (and shared/locking) pieces again this week but overall, my understanding of how modern operating systems handle multitasking has certainly deepened.

Comments

Popular posts from this blog

Introduction and First Post!

Week 2: Learning Strategy Reflections, Time Management Activity Log, Project Management Basics, Previous Capstones That Interest Me, Weekly Reflection

Educational Goals, Career Goals, ETS Comp Sci Test Estimate, and Weekly Reflection