#StackBounty: #linux-kernel #process-management #synchronization #pthreads What is the process state when pthread_mutex() is executed

Bounty: 50

Following are the Linux Process states;

R: running or runnable, it is just waiting for the CPU to process it
S: Interruptible sleep, waiting for an event to complete, such as input from the terminal
D: Uninterruptible sleep, processes that cannot be killed or interrupted with a signal, usually to make them go away you have to reboot or fix the issue
Z: Zombie, we discussed in a previous lesson that zombies are terminated processes that are waiting to have their statuses collected
T: Stopped, a process that has been suspended/stopped

I have two questions;

(1) When a mutex_lock() is called in a process/thread, and if it is waiting for the lock to acquire(another thread locked the mutex already), will the process go to S or D?

(2) I know that spinlock() will put the process in busy waiting and it checks to see if the lock is unlocked by other thread. However in mutex_lock() how it knows that the lock is unlocked and it is available to lock and proceed? i.e; How the process wakes up from sleep to lock the mutex when it is available(unlocked by other thread)?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.