lpcware

PT_SPAWN problem

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Lumos on Wed Nov 21 06:34:08 MST 2012
Hello, I would like to describe my problem with PT_SPAWN macro in my project.
I am using PT_SPAWN macro to schedule child protothread and within this child protothread is used PT_YIELD macro. Such using of PT_YIELD macro leads to situation, that parent protothread does not wait for complete execution of child protothread, but continues after first occurence of PT_YIELD.

This is caused by calling of PT_SCHEDULE macro inside and this macro is defined as ((f) == PT_WAITING). It means parent protothread is waiting while child protothread is returning PT_WAITING. But if PT_YIELDED is returned, parent protothread continue. This is not correct, because child protothread was yielded only, not finished.

Is my understanding wrong? How this problem can be solved?
Thank you

Outcomes