Week 30

     This week's material deepened my understanding of concurrency control and how it can get out of control. Semaphores emerged as a synchronization tool, functioning as both locks and condition variables. Their atomic operations, sem_wait() and sem_post(), enable thread coordination, enforcing mutual exclusion in critical sections or guaranteeing execution order. Improper usage risks deadlocks, as seen in the dining philosophers problem, where circular wait conditions arise unless lock acquisition is carefully ordered.

    The readings from this week also highlighted non-deadlock concurrency bugs, which happen a lot in real-world systems. Atomicity violations, like a thread interrupted between checking and using a pointer-expose flawed assumptions about uninterrupted execution. Order violations, where threads rely on unchecked execution sequences, further underscore the need for synchronization primitives to enforce correctness. Deadlocks remain insidious, requiring strategies like lock hierarchies or avoidance algorithms to break the four deadly conditions: mutual exclusion, hold-and-wait, no preemption, and circular wait.

    I also read about the contrast between processes and threads' trade-offs. Processes offer isolation by operating in separate memory spaces, which enhances security and fault tolerance. If one process crashes, others remain unaffected. However, this isolation comes at a cost: higher overhead due to the need for interprocess communication mechanisms like pipes or shared memory, and slower context switching as the OS must swap entire address spaces.

    Threads, on the other hand, share the same memory space within a process, enabling faster communication via shared variables and lower overhead for creation and context switching. This makes threads ideal for performance-sensitive tasks, such as parallelizing computations or handling multiple requests in a web server. However, this efficiency demands meticulous synchronization- locks, semaphores, or condition variables, to prevent race conditions, deadlocks, or corrupted data. 

Comments

Popular posts from this blog

Week 1

Week 4

Week 2