This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

CMSIS-RTX does osThreadgetId() switching Threads?

Hi,

Inside of the SEGGER emwin Library is a locking funktion wich takes care of being used by different threads. These locks are using a single binary semaphore. The pseudocode for the lock is something like:

if (entrancecount == 0)
{
  osSemaphoreWait(guisem, osWaitForever);
  taskidlock = osGetThreadId();
}
else
{
  if (taskidlock != osGetThreadId())
  {
    osSemaphoreWait(guisem, osWaitForever);
    taskidlock = osGetThreadId();
  }
}

This seems to be OK, but only when there is no thread switch between the return of osSemaphoreWait and the return of osGetThreadId. Both are implemented as SVC functions. Is it possible that a thread switch occurs between both calls and if yes, how can i avoid them?

I am using CMSIS-RTX 4.8 with Keil MDK 5.21 on an STM32F429 Cortex-M4

Thank you
Martin