Implement chMsgSend, chMsgWait with timeout

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
lqv
Posts: 5
Joined: Mon May 12, 2014 10:14 am

Implement chMsgSend, chMsgWait with timeout

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Implement chMsgSend, chMsgWait with timeout

Post by Giovanni »

Hi,

Currently it is not planned. You may use mailboxes if you need timeouts.

Giovanni
lqv
Posts: 5
Joined: Mon May 12, 2014 10:14 am

Re: Implement chMsgSend, chMsgWait with timeout

Post 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!
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Implement chMsgSend, chMsgWait with timeout

Post 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
lqv
Posts: 5
Joined: Mon May 12, 2014 10:14 am

Re: Implement chMsgSend, chMsgWait with timeout

Post by lqv »

Thank you for helping me. I will try two mailboxes.
PS: sorry for my poor English, it is not my native language :oops:
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Implement chMsgSend, chMsgWait with timeout

Post 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 :oops:


Nor it is mine, so why bother :)
Post Reply