Week 29: Concurrency

Concurrency relies on interlacing multiple processes where as multi-threading allows for multiple processes to run in parallel which is called parallelization. With multi-threading your program runs across multiple processors and each thread has its own program counter to run its instructions. By using multi-threading we are also able to avoid blocking I/O. The downside to threads is that all threads have access to the same address thus shared resources in the stack may be altered in different order because of the scheduler which can become an issue as we see in our lab activity. This essentially is what we call a race condition

Next key topic I learned about was Locks. Locks are used by programmers to ensure that any critical section executes as a single atomic instruction. Locks are simply a variable that have state of the lock at any point in time. Generally they are either available/unlocked/free or acquired/locked/held. There are two main locks covered in the reading, Spin locks and ticket locks. Spin locks essentially constantly check to see if the lock is unlocked where as ticket locks utilize a FIFO method where each thread is assigned a number in the queue and served as such.