locks.h File Reference
Go to the source code of this file.
Detailed Description
Locking API for libthreads.
- Todo:
- Semaphores and mutexes should have a queue of threads that are waiting for a lock, then wake one whenever the lock is unlocked. (thanks tueidj)
Function Documentation
Creates a mutex.
- Returns:
- A mutex object.
| int mutexes_lock_noblock |
( |
mutex_t * |
m |
) |
|
Locks a mutex.
This call is nonblocking, thus it is safe to use within an interrupt handler or a threads_freeze() block. It will return no matter whether it succeeded or failed.
- Parameters:
-
| m | a pointer to the mutex to lock. |
- Returns:
- 1 if the mutex was able to be locked, 0 if it was not.
- See also:
- mutexes_lock(), mutexes_unlock()
| void mutexes_unlock |
( |
mutex_t * |
m |
) |
|
Creates a semaphore.
- Parameters:
-
| count | how many locks the semaphore may take before waiting. |
- Returns:
- A semaphore object with the requested specification.
Locks a semaphore.
This call is nonblocking, thus it is safe to use within an interrupt handler or a threads_freeze() block. It will return no matter whether it succeeded or failed.
- Parameters:
-
| s | a pointer to the semaphore to lock. |
- Returns:
- 1 if the semaphore was able to be locked, 0 if it was not.
- See also:
- semaphores_lock(), semaphores_unlock()