Mutexes in the Linux kernel

Mutex means mutual Exclusion. The mutex provides a mechanism to protect critical data. The mutex allows a process/thread to go to sleep state in case the lock cannot be acquired immediately. This is in contrast to a spinlock wherein the calling process/thread keeps spinning at obtaining the lock and does not go down to sleep. […]

Mutex API

The Mutex API can be defined statically using the “DEFINE_MUTEX” MACRO. It can be dynamically defined during process/thread run using the “mutex_init” MACRO. Both methods are shown below DEFINE_MUTEX(mutex_name); /*statically assign mutex by name- mutex_name*/ mutex_init(mutex); /* dynamically assign the mutex */ Both these Macros are placed in the header file – mutex.h. The code […]

Linux Kernel – Debug File System

The Linux Debug File System is a virtual memory File system that was developed so that debug kernel information can be accessed in user space whenever desired. It is a RAM based File system. The Debug File system will be enabled in the Linux kernel build if “CONFIG_DEBUG_FS” is enabled in the kernel config. The […]