Script to detect deadlocks in C/C++ code in GNU Debugger
This script will help you automate deadlock detection in compiled C/C++ code
with GNU Debugger. I think this is interesting because deadlock detection itself
is an NP-hard problem.
Banker’s Algorithm
Banker’s Algorithm is a resource allocation and deadlock avoidance algorithm
by simulating the allocation of predetermined possible amounts of all resources.
This algorithm is used majorly on banking systems to avoid deadlock and identify
whether a loan will be given or not.
You’ve met Deadlocks, but what about Livelocks?
TL;DR Livelock is another concurrency problem and is similar to deadlock.
Livelock, two or more threads keep on transferring states between one another
instead of waiting infinitely. Because of that the threads are not able to
perform their respective tasks.
The Dining Philosophers Problem (and solution)
The Dining Philosophers Problem is an interesting problem because it introduces
management of scarce, shared resources but is quite tricky because naive
solution will always result in deadlocks. This article breaks down the problem
and help us understand the solution without introducing deadlocks.
Mutex Synchronization in Linux with Pthreads (Video)
Pretty much what the title says. It’s a demo on how to use mutex using
pthread.h
. This would help you understand mutexes because the video will show
you the solution from naive solution to proper mutexes as well as explaining
each step’s pros and cons.
What the hell is Futex!?
You might have heard about mutex, but do you know there’s a thing called Futex?
Futex stands for “Fast Userspace Mutex”. As the name suggest, it’s just mutex
in userspace to favor performance. This article explain the basics of futex and
also provide code examples you can try.
Introduction to Spinlocks
Spinlocks is another synchronization mechanism which consist of two states:
acquired
and released
. However, I don’t think Spinlocks is as popular as
semaphore and mutex since it’s quite difficult for me to find this site. But
it’s a neat knowledge never the less.
Spinlocks Considered Harmful
Not long after I discovered Spinlocks, I also discovered why spinlocks is not as
popular as other synchronization mechanism. It is apparently quite dangerous and
generally not recommended it full of flaws. The article provide examples in rust
that you can try.
Sequence Lock (seqlock) in Linux Kernel
Seqlocks is very useful synchronization mechanism to provide a lightweight and
scalable lock for the scenario where many readers and a few writers are present.
With seqlocks you can avoid writer starvation. This article is very neat to read
and gives detailed info about seqlocks.
The Sleeping Barber problem
Yet another classic IPC (inter-process communication) problem. This article
covers how we can approach the problem and eventually came with a solution and a
visualization as well to help understand the solution better. I highly recommend
you to read this article.
That’s all folks, hope you all doing well. See you on Week 08.