我正在使用Rime,更具体地说,使用runicast示例。收到消息后,我将其存储在链接列表中,然后将事件发送到负责从链接列表中提取消息并处理消息的进程。我的代码是这样的:
static void recv_runicast(struct runicast_conn *c,
const linkaddr_t *from, uint8_t seqno)
{
/*code to insert the message into the linked list*/
...
/*Post an event to the process which extracts messages from the linked list */
process_post(&extract_msg_from_linked_list, PROCESS_EVENT_CONTINUE, NULL);
}我的问题是:在回调函数process_post中使用recv_runicast安全吗?还是我应该使用process_poll?
提前感谢
发布于 2017-04-13 09:50:16
是的,很安全。网络堆栈操作是在进程上下文中完成的,Contiki进程不是抢占性的。因此,几乎所有与流程相关的操作都是“安全的”。
process_post和process_poll的主要区别在于前者将在process缓冲区中放置一个新事件,而后者只设置一个标志。因此,第二种方案的效率略高。此外,从理论上讲,事件缓冲区可能会满,事件开始丢失,但这不太可能是个问题。
我完全不使用这些函数,而是直接在回调中进行处理,以简化执行流程。
https://stackoverflow.com/questions/43379743
复制相似问题