Skip to Content
Linux Device Drivers Development
book

Linux Device Drivers Development

by John Madieu
October 2017
Intermediate to advanced
586 pages
14h 8m
English
Packt Publishing
Content preview from Linux Device Drivers Development

Acquire and release

  • Lock:
void mutex_lock(struct mutex *lock); 
int  mutex_lock_interruptible(struct mutex *lock); 
int  mutex_lock_killable(struct mutex *lock); 
  • Unlock:
void mutex_unlock(struct mutex *lock); 

Sometimes, you may only need to check whether a mutex is locked or not. For that purpose, you can use the int mutex_is_locked(struct mutex *lock) function:

int mutex_is_locked(struct mutex *lock); 

What this function does is just check whether the mutex's owner is empty (NULL) or not. There is also mutex_trylock, which acquires the mutex if it is not already locked and returns 1; otherwise, it returns 0:

int mutex_trylock(struct mutex *lock); 

As with the wait queue's interruptible family function, mutex_lock_interruptible(), which ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Device Drivers, Second Edition

Linux Device Drivers, Second Edition

Jonathan Corbet, Alessandro Rubini
Linux Device Drivers, 3rd Edition

Linux Device Drivers, 3rd Edition

Jonathan Corbet, Alessandro Rubini, Greg Kroah-Hartman

Publisher Resources

ISBN: 9781785280009Supplemental Content