The below code creates a directory in “/sys/kernel/debug” and a value is written to file and read from file. The code and the “Makefile” for compiling the code are provided below: In the above code example, the file created is “value” inside the folder “/sys/kernel/debug/debug_dir_example“. When “debugfs_create_file” API is invoked, the “data” parameter (accessed in […]
Mutex API List and Sample API Code
A few of the mutex APIs are provided below #define mutex_init(mutex) Initialize the mutex to unlocked state. This Macro invokes the function __mutex_init void __sched mutex_lock(struct mutex *lock) Acquire the lock void __sched mutex_unlock(struct mutex *lock) Release the Mutex int __sched mutex_lock_interruptible(struct mutex *lock) Acquire the Mutex, interruptible by signals. If a signal is delivered […]
Semaphore Example implementation
The below code examples provide a simple usage of a semaphore for static and dynamic initialization. This code does not provide an actual use case but only indicates the manner in which the API needs to be invoked. Static semaphore initialization and use: Dynamic Semaphore initialization and use In the following articles, we will look […]