aboutsummaryrefslogtreecommitdiff
path: root/applications/threadx_demo/main.cpp
diff options
context:
space:
mode:
authorLedion Daja <ledion.daja@arm.com>2022-04-05 15:04:11 +0200
committerLedion Daja <ledion.daja@arm.com>2022-05-04 15:37:50 +0200
commit60c5737c37471b4e34f1ffc085e8b12e2a7c6866 (patch)
tree8ea4ef8763c2f10508b02b859a9ad0723e46a1ed /applications/threadx_demo/main.cpp
parent134c39e5e95725d2f79ed2b8cf215d336cc46cd0 (diff)
downloadethos-u-core-platform-60c5737c37471b4e34f1ffc085e8b12e2a7c6866.tar.gz
Change return value of mutex and semaphore handling functions
Changed mutex lock/unlock and semaphore take/give functions to return an int value instead of void. In addition changed FreeRTOS and message_handler applications (also FreeRTOS-based) to ignore failure of xSemaphoreGive on binary semaphores, as it does not affect the correctness of such applications. Change-Id: I023c62dc8971488107679f6dd7a5967dec0380a8
Diffstat (limited to 'applications/threadx_demo/main.cpp')
-rw-r--r--applications/threadx_demo/main.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/applications/threadx_demo/main.cpp b/applications/threadx_demo/main.cpp
index bf65085..cbf1661 100644
--- a/applications/threadx_demo/main.cpp
+++ b/applications/threadx_demo/main.cpp
@@ -144,22 +144,24 @@ void *ethosu_mutex_create(void) {
return (void *)mutex;
}
-void ethosu_mutex_lock(void *mutex) {
+int ethosu_mutex_lock(void *mutex) {
UINT status;
status = tx_mutex_get(reinterpret_cast<TX_MUTEX *>(mutex), TX_WAIT_FOREVER);
if (status != TX_SUCCESS) {
printf("mutex get failed, error - %d\n", status);
+ return -1;
}
- return;
+ return 0;
}
-void ethosu_mutex_unlock(void *mutex) {
+int ethosu_mutex_unlock(void *mutex) {
UINT status;
status = tx_mutex_put(reinterpret_cast<TX_MUTEX *>(mutex));
if (status != TX_SUCCESS) {
printf("mutex put failed, error - %d\n", status);
+ return -1;
}
- return;
+ return 0;
}
void *ethosu_semaphore_create(void) {
@@ -176,28 +178,30 @@ void *ethosu_semaphore_create(void) {
return (void *)semaphore;
}
-void ethosu_semaphore_take(void *sem) {
+int ethosu_semaphore_take(void *sem) {
UINT status;
status = tx_semaphore_get(reinterpret_cast<TX_SEMAPHORE *>(sem), TX_WAIT_FOREVER);
if (status != TX_SUCCESS) {
printf("Semaphore get/take, error - %d\n", status);
+ return -1;
}
- return;
+ return 0;
}
-void ethosu_semaphore_give(void *sem) {
+int ethosu_semaphore_give(void *sem) {
UINT status;
status = tx_semaphore_put(reinterpret_cast<TX_SEMAPHORE *>(sem));
if (status != TX_SUCCESS) {
printf("Semaphore put/give, error - %d\n", status);
+ return -1;
}
- return;
+ return 0;
}
}