Mutex api, Altera_avalon_mutex_is_mine(), Mutex api -3 – Altera Embedded Peripherals IP User Manual
Page 260: Altera_avalon_mutex_is_mine() -3

Function Name
Description
altera_avalon_mutex_trylock()
Tries to lock the mutex. Returns immediately if it fails to
lock the mutex.
altera_avalon_mutex_lock()
Locks the mutex. Will not return until it has successfully
claimed the mutex.
altera_avalon_mutex_unlock()
Unlocks the mutex.
altera_avalon_mutex_is_mine()
Determines if this CPU owns the mutex.
altera_avalon_mutex_first_
lock()
Tests whether the mutex has been released since reset.
These routines coordinate access to the software mutex structure using a hardware mutex core. For a
complete description of each function, see section the Mutex API section.
The code shown in below demonstrates opening a mutex device handle and locking a mutex.
#include
/* get the mutex device handle */
alt_mutex_dev* mutex = altera_avalon_mutex_open( “/dev/mutex” );
/* acquire the mutex, setting the value to one */
altera_avalon_mutex_lock( mutex, 1 );
/*
* Access a shared resource here.
*/
/* release the lock */
altera_avalon_mutex_unlock( mutex );
Mutex API
This section describes the application programming interface (API) for the mutex core.
altera_avalon_mutex_is_mine()
Prototype:
int altera_avalon_mutex_is_mine(alt_mutex_dev* dev)
Thread-safe:
Yes.
Available from
ISR:
No.
Include:
<
altera_avalon_mutex.h
>
Parameters:
dev
—the mutex device to test.
Returns:
Returns non zero if the mutex is owned by this CPU.
Description:
altera_avalon_mutex_is_mine()
determines if this CPU owns the mutex.
UG-01085
2014.24.07
Mutex API
26-3
Mutex Core
Altera Corporation