Home | Projects | Notes > Multi-Threading (POSIX Threads) > Thread Synchronization - Thread-Safe Highly Concurrent CRUD Operations

Thread Synchronization - Thread-Safe Highly Concurrent CRUD Operations

 

Consider this section as one of the most important section in the thread synchronization. In this section we will explore how to implement thread-safe bullet-proof CRUD operations.

 

What are CRUD Operations?

 

Introduction to Thread-Safe Highly Concurrent CRUD Operations

 

Goals of Thread-Safe Highly Concurrent CRUD Operations

 

Tools Necessary for Thread-Safe Highly Concurrent CRUD Operations

In order to implement thread-safe highly concurrent CRUD operations on a data structure, we need to have:

  1. Read/write locks (not regular mutexes)

    • An RW lock at the container level

    • An RW lock at the container element level

  2. A reference count object per container (prevent premature deletion of an object)

1. Read/Write Locks

Locking Rules

2. Reference Count Object

Reference Counting Rules

 

CRUD Algorithms

We are still using the student & student list example! See how thread-safe and high-concurrency are achieved!

 

Checking Robustness of Our CRUD Algorithm

 

update-delete-threads-sequence-diagram-case-1

 

update-delete-threads-sequence-diagram-case-2

 

update-delete-threads-sequence-diagram-case-3

 

 

References

Sagar, A. (2022). Part A - Multithreading & Thread Synchronization - Pthreads [Video file]. Retrieved from https://www.udemy.com/course/multithreading_parta/