Chris Solomon

Suggested improvement for lwsem

Discussion created by Chris Solomon on Aug 31, 2014
Latest reply on Sep 1, 2014 by Chris Solomon

Hi,

we have just spend a few days tracking down a bug in our application, (running on MQX 4.0.1).

The problem ended up being tracked down to lw semaphores being in the linked list after they were freed by task destruction.

Subsequent allocation reused the memory, so the behavior was unpredictable and changed with seemingly unrelated alterations.

 

I know this can be solved by putting the semaphore struct pointers into a context and having a task exit function, but I this is laborious.

I suggest that in the default task exit handler, prior to freeing memory allocated by the task, the semaphore linked list be checked to see if the any of the semaphore structures are within blocks to be freed.

 

I realize that this is an overhead, but task destruction is not done frequently.

 

Thoughts?

 

Chris

Outcomes