cancel
Showing results for 
Search instead for 
Did you mean: 

CMSIS RTOS Variable Problem

kasun_duminda92
Associate III
Posted on July 02, 2013 at 17:56

This discussion was mistakenly add in this section. It should be in the STM32 Discovery section. So it was moved there.

#discovery #stm32 #rtos #cmsis
2 REPLIES 2
dthedens23
Associate II
Posted on July 02, 2013 at 20:18

I cannot say why it is hanging.  perhaps your stack size is way to small?

osThreadDef(Funct, osPriorityNormal, 1, 256);

Waking a thread every 1ms is pretty harsh.  Try every 50ms and increment count by 50.

I can say that you have two threads nakedly accessing the same variable.  That access is not thread safe,

First, the variable should use the keyword ''volatile''

second, there should be a mutex that each thread calls to gain access to the variable.  Only one thread at a time can ''hold'' the variable, to read or modify and then, the thread releases the mutex.

NOTE: in this simple example it might not matter to much, since one thread is the consumer and the other thread is the provider.  But naked access will cause problems.

Amel NASRI
ST Employee
Posted on July 30, 2013 at 10:40

Details in STM32 Discovery forum:

https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/CMSIS%20RTOS%20Problem&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&currentviews=30

.

Replies should be given there.

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.