From 96d6da4e252b06dcfdc041e7df23e86161c33007 Mon Sep 17 00:00:00 2001 From: rihab kouki Date: Tue, 28 Jul 2020 11:24:49 +0100 Subject: Official ARM version: v5.6.0 --- docs/RTOS2/html/group__CMSIS__RTOS__MutexMgmt.html | 78 +++++++++++----------- 1 file changed, 39 insertions(+), 39 deletions(-) (limited to 'docs/RTOS2/html/group__CMSIS__RTOS__MutexMgmt.html') diff --git a/docs/RTOS2/html/group__CMSIS__RTOS__MutexMgmt.html b/docs/RTOS2/html/group__CMSIS__RTOS__MutexMgmt.html index 9b6d2ee..e094921 100644 --- a/docs/RTOS2/html/group__CMSIS__RTOS__MutexMgmt.html +++ b/docs/RTOS2/html/group__CMSIS__RTOS__MutexMgmt.html @@ -254,18 +254,18 @@ size of provided memory for control block

The size (in bytes) of memory block

Note
The maximum amount of recursive locks possible is implementation specific, i.e. the type size used for the lock count. If the maximum amount of recursive locks is depleted mutex acquire might fail.

Code Example

#include "cmsis_os2.h"
-
-
osMutexId_t mutex_id;
-
+
+
osMutexId_t mutex_id;
+
const osMutexAttr_t Thread_Mutex_attr = {
"myThreadMutex", // human readable mutex name
osMutexRecursive, // attr_bits
NULL, // memory for control block
0U // size for control block
};
-
+
// must be called from a thread context
-
void UseMutexRecursively(int count) {
+
void UseMutexRecursively(int count) {
osStatus_t result = osMutexAcquire(mutex_id, osWaitForever); // lock count is incremented, might fail when lock count is depleted
if (result == osOK) {
if (count < 10) {
@@ -292,38 +292,38 @@ size of provided memory for control block

The size (in bytes) of memory block

Code Example

This example reveals a blocked high priority thread if osMutexPrioInherit is removed.

#include "cmsis_os2.h"
-
+
osMutexId_t mutex_id;
-
+
const osMutexAttr_t Thread_Mutex_attr = {
"myThreadMutex", // human readable mutex name
osMutexPrioInherit, // attr_bits
NULL, // memory for control block
0U // size for control block
};
-
+
void HighPrioThread(void *argument) {
-
osDelay(1000); // wait 1s until start actual work
+
osDelay(1000U); // wait 1s until start actual work
while(1) {
osMutexAcquire(mutex_id, osWaitForever); // try to acquire mutex
// do stuff
osMutexRelease(mutex_id);
}
}
-
+
void MidPrioThread(void *argument) {
-
osDelay(1000); // wait 1s until start actual work
+
osDelay(1000U); // wait 1s until start actual work
while(1) {
// do non blocking stuff
}
}
-
+
void LowPrioThread(void *argument) {
while(1) {
-
osDelay(5000); // block mutex for 5s
+
osDelay(5000U); // block mutex for 5s
osMutexRelease(mutex_id);
-
osDelay(5000); // sleep for 5s
+
osDelay(5000U); // sleep for 5s
}
}

During the first second the high and mid priority threads are delayed. Thus the low priority thread can start its work, acquires the mutex and delays while holding it.

@@ -348,16 +348,16 @@ size of provided memory for control block

The size (in bytes) of memory block

Code Example

This example reveals a blocked mutex if osMutexRobust is removed.

#include "cmsis_os2.h"
-
-
osMutexId_t mutex_id;
-
+
+
osMutexId_t mutex_id;
+
const osMutexAttr_t Thread_Mutex_attr = {
"myThreadMutex", // human readable mutex name
osMutexRobust, // attr_bits
NULL, // memory for control block
0U // size for control block
};
-
+
void Thread(void *argument) {
@@ -410,21 +410,21 @@ size of provided memory for control block

The size (in bytes) of memory block

Note
This function cannot be called from Interrupt Service Routines.

Code Example

#include "cmsis_os2.h"
-
+
osMutexId_t mutex_id;
-
+
const osMutexAttr_t Thread_Mutex_attr = {
"myThreadMutex", // human readable mutex name
NULL, // memory for control block
0U // size for control block
-
};
-
+
};
+
void CreateMutex (void) {
mutex_id = osMutexNew(&Thread_Mutex_attr);
if (mutex_id != NULL) {
// Mutex object created
-
}
+
}
}
@@ -496,21 +496,21 @@ size of provided memory for control block

The size (in bytes) of memory block

Note
This function cannot be called from Interrupt Service Routines.

Code Example

#include "cmsis_os2.h"
-
-
void WaitMutex (void) {
-
osMutexId_t mutex_id;
-
osStatus_t status;
+
+
void WaitMutex (void) {
+
osMutexId_t mutex_id;
+
osStatus_t status;
mutex_id = osMutexNew(NULL);
-
if (mutex_id != NULL) {
-
status = osMutexAcquire(mutex_id, 0);
+
if (mutex_id != NULL) {
+
status = osMutexAcquire(mutex_id, 0U);
if (status != osOK) {
// handle failure code
}
@@ -543,19 +543,19 @@ size of provided memory for control block

The size (in bytes) of memory block

Possible osStatus_t return values:

  • osOK: the mutex has been correctly released.
  • +
  • osErrorResource: the mutex could not be released (mutex was not acquired or running thread is not the owner).
  • osErrorParameter: parameter mutex_id is NULL or invalid.
  • -
  • osErrorResource: the mutex specified by parameter mutex_id is in an invalid mutex state or the mutex was not obtained before/the current thread is not the owner of the mutex.
  • osErrorISR: osMutexRelease cannot be called from interrupt service routines.
Note
This function cannot be called from Interrupt Service Routines.

Code Example

#include "cmsis_os2.h"
-
+
osMutexId_t mutex_id; // Mutex id populated by the function osMutexNew()
-
void ReleaseMutex (osMutexId_t mutex_id) {
+
void ReleaseMutex (osMutexId_t mutex_id) {
osStatus_t status;
-
+
if (mutex_id != NULL) {
status = osMutexRelease(mutex_id);
if (status != osOK) {
@@ -616,18 +616,18 @@ size of provided memory for control block

The size (in bytes) of memory block

  • osOK: the mutex object has been deleted.
  • osErrorParameter: parameter mutex_id is NULL or invalid.
  • -
  • osErrorResource: the mutex specified by parameter mutex_id is in an invalid mutex state.
  • +
  • osErrorResource: the mutex is in an invalid state.
  • osErrorISR: osMutexDelete cannot be called from interrupt service routines.
Note
This function cannot be called from Interrupt Service Routines.

Code Example

#include "cmsis_os2.h"
-
-
osMutexId_t mutex_id; // Mutex id populated by the function osMutexNew()
+
+
osMutexId_t mutex_id; // Mutex id populated by the function osMutexNew()
void DeleteMutex (osMutexId_t mutex_id) {
osStatus_t status;
-
+
if (mutex_id != NULL) {
status = osMutexDelete(mutex_id);
if (status != osOK) {
@@ -643,7 +643,7 @@ size of provided memory for control block

The size (in bytes) of memory block