When to Use Mutex_Lock_Interruptible?

When to Use Mutex_Lock_Interruptible?

Use mutex_lock_interruptible() function to allow your driver to be interrupted by any signal. This implies that your system call should be written so that it can be restarted. (Also see ERESTARTSYS.)

Can I lock a spinlock in one CPU and unlock it another CPU?

Using spinlocks on a single-core/single-CPU system makes usually no sense, since as long as the spinlock polling is blocking the only available CPU core, no other thread can run and since no other thread can run, the lock won't be unlocked either.

Can I call Kmalloc Gfp_kernel while holding a spinlock?

You cannot, however, do anything that will sleep while holding a spinlock. For example, never call any function that touches user memory, kmalloc() with the GFP_KERNEL flag, any semaphore functions or any of the schedule functions while holding a spinlock. ... Semaphores in Linux are sleeping locks.

Sarah Jenkins
Author

Sarah Jenkins

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.