博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
内核mailbox
阅读量:7020 次
发布时间:2019-06-28

本文共 1241 字,大约阅读时间需要 4 分钟。

只罗列增加取走消息:

static int add_to_rbuf(struct mbox_chan *chan, void *mssg){    int idx;    unsigned long flags;    spin_lock_irqsave(&chan->lock, flags);    /* See if there is any space left */    if (chan->msg_count == MBOX_TX_QUEUE_LEN) {        spin_unlock_irqrestore(&chan->lock, flags);        return -ENOBUFS;    }    idx = chan->msg_free;    chan->msg_data[idx] = mssg;    chan->msg_count++;    if (idx == MBOX_TX_QUEUE_LEN - 1)        chan->msg_free = 0;    else        chan->msg_free++;    spin_unlock_irqrestore(&chan->lock, flags);    return idx;}static void msg_submit(struct mbox_chan *chan){    unsigned count, idx;    unsigned long flags;    void *data;    int err;    spin_lock_irqsave(&chan->lock, flags);    if (!chan->msg_count || chan->active_req)        goto exit;    count = chan->msg_count;    idx = chan->msg_free;    if (idx >= count)        idx -= count;    else        idx += MBOX_TX_QUEUE_LEN - count;    data = chan->msg_data[idx];    /* Try to submit a message to the MBOX controller */    err = chan->mbox->ops->send_data(chan, data);    if (!err) {        chan->active_req = data;        chan->msg_count--;    }exit:    spin_unlock_irqrestore(&chan->lock, flags);}

 

转载于:https://www.cnblogs.com/vedic/p/10773939.html

你可能感兴趣的文章
软件测试(四)主路径覆盖hw3
查看>>
【转载】C# DataGridView 通过代码设置样式
查看>>
StringTokenizer 简单的描述
查看>>
程序员成长路上的团队修炼之道
查看>>
linux command
查看>>
如何用Maven创建web项目
查看>>
Since150910
查看>>
汇编第五章总结
查看>>
HTML常见元素集锦
查看>>
[翻译文章]javascript的对象(how javascript objects works?)
查看>>
关于登录与购买和数据模块
查看>>
第 3 章 镜像 - 012 - 构建镜像
查看>>
dp【多进程类】
查看>>
简易抽取
查看>>
js转html实体
查看>>
django框架数据库相关操作
查看>>
FreeSWITCH增加iLBC编码
查看>>
PostgreSQL在线安装
查看>>
iOS中有两种支持机制:Notification和KVO(Key-Value Observing)
查看>>
准备从头复习算法
查看>>