zoukankan      html  css  js  c++  java
  • 内核mailbox

    只罗列增加取走消息:

    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);
    }
  • 相关阅读:
    uva10285 Longest Run on a Snowboard(DP)
    typecho 0.8 营销引擎
    新浪博客营销插件
    忍者X3备份说明
    QQ空间、说说抓取引擎
    yiqicms发布插件的使用
    SHOPEX v4.85 发布插件
    ecshop2.73插件使用帮助
    Destoon V5 发布插件
    Wordpress3.52营销引擎
  • 原文地址:https://www.cnblogs.com/vedic/p/10773939.html
Copyright © 2011-2022 走看看