Page 1 of 1
Implement chMsgSend, chMsgWait with timeout
Posted: Mon May 12, 2014 10:57 am
by lqv
Can ChibiOS support these function in the future? I tried to change "chSchGoSleepS" to "chSchGoSleepTimeoutS", But i don't know how to handle the message queue in timeout case.
Re: Implement chMsgSend, chMsgWait with timeout
Posted: Mon May 12, 2014 1:10 pm
by Giovanni
Hi,
Currently it is not planned. You may use mailboxes if you need timeouts.
Giovanni
Re: Implement chMsgSend, chMsgWait with timeout
Posted: Mon May 12, 2014 4:51 pm
by lqv
Hi Giovanni
Thanks for the quick reply. I have tried the mailboxes. But in my case, i want to suspend the sending thread (with a timeout) when passing a message and release it when the job's done. Could you please give me some advice for this!
Re: Implement chMsgSend, chMsgWait with timeout
Posted: Mon May 12, 2014 5:16 pm
by Giovanni
Hi,
You can use two mailboxes in the two directions one for messages, the other for answers, or a mailbox and an event source as answer.
Note that implementing timeouts on chMsgSend() is not possible because after waking up the receiving thread it is not more possible to withdraw the operation asynchronously because a timeout, there would be an inherent race condition: it is not possible to abort the send after that the message processing has begun.
Giovanni
Re: Implement chMsgSend, chMsgWait with timeout
Posted: Mon May 12, 2014 7:09 pm
by lqv
Thank you for helping me. I will try two mailboxes.
PS: sorry for my poor English, it is not my native language

Re: Implement chMsgSend, chMsgWait with timeout
Posted: Mon May 12, 2014 7:39 pm
by Giovanni
lqv wrote:Thank you for helping me. I will try two mailboxes.
PS: sorry for my poor English, it is not my native language

Nor it is mine, so why bother
