lock: mutex/spinlock/shared lock
mutex( x lock): when a mutex lock is obtained, others cannot obtain the same mutex while the lock is not freed.
shared lock( s lock): when a shared lock is obtained, others can obtain the shared lock, but the mutex lock cannot be obtained while any one holding a shared lock. While holding the shared lock, only read data is permitted. One cannot write data while holding a shared lock.
spin lock: different kind of mutex, which implemented as keep trying to get the non-shared lock. (When trying to get the mutex, the thread might get switched out of the cpu(sleep), however the spin lock keeps running on the cpu.)
Anyone is permitted to copy/use the contents and codes from this blog.
Sansna is not going to guarantee anything, Sansna will not take any responsibility of any results after using these codes/contents.