![]() |
mutex
Vitis Drivers API Documentation
|
This file contains a design example for using the Mutex hardware and driver XMutex.
The example assumes there are two processors availabile in the system that are expected to inter-communicate.
This example attempts to lock the Mutex from the processor identified as 0 (XPAR_CPU_ID=0) to prevent the other processor from getting the lock. Since the application is running on two seperate processors, the initiator declares success when the Mutex locks the other processor declares success when the Mutex is locked from its perspective. There is no feedback to the initiator so a terminal is required for each processor to verify that the test passed for both sides.
This example has been tested on ML505 Hardware Evaluation board.
These code fragments will illustrate how the XMutex driver can be used to:
MODIFICATION HISTORY:
Ver Who Date Changes
1.00a va First release 1.00a ecm 06/04/07 Cleanup, new coding standard, check into XCS 1.00a ecm 08/28/08 Converted to testapp example 3.01a sdm 05/04/10 Removed printfs from the MutexExample 4.2 ms 01/23/17 Modified xil_printf statement in main function to ensure that "Successfully ran" and "Failed" strings are available in all examples. This is a fix for CR-965028. 4.7 ht 06/21/23 Added support for system device-tree flow.
*
Macros | |
#define | MUTEX_NUM 0 |
The Mutex number on which this example is run. More... | |
Functions | |
int | MutexExample (u16 MutexDeviceID) |
This function contains the actual functionality for the XMutex TestApp example. More... | |
int | main (void) |
This function is the main function for the Mutex example. More... | |
#define MUTEX_NUM 0 |
The Mutex number on which this example is run.
Referenced by MutexExample().
int main | ( | void | ) |
This function is the main function for the Mutex example.
None. |
int MutexExample | ( | u16 | MutexDeviceID | ) |
This function contains the actual functionality for the XMutex TestApp example.
he idea is to have this application running on two processors which share the same bus and have access to the Mutex hardware. CPU 0 is considered the primary CPU since it is the one which is expected to initially lock the Mutex.
MutexDeviceID | is the device id to be initialized and used. |
References XMutex_Config::BaseAddress, MUTEX_NUM, XMutex_CfgInitialize(), XMutex_Lock(), XMutex_Trylock(), and XMutex_Unlock().