Git Product home page Git Product logo

kfifo's Introduction

kfifo

内核的kfifo

使用环境

  • kfifo_init可以单独使用但需要注意kfifo的大小需为2的幂次方倍,否则算出的偏移不对offset
  • 参考main.c中的例子
  • 根据需要定义KFIFO_EXT
  • kfifo笔记

使用须知

所有使用需要使用kfifo_out进行获取fifo中的值,不要试图直接使用fifo中的fifo->buffer+kfifo_tail() kfifo_tail()返回的结果为0->(size-1),tail值可能为kfifo的尾边界,实在要获取在靠近边界时需要将数据通过fifo_out copy出来 如下:

    if (kfifo_tail(&prtFifo) + MAX_LINE_CHAR > 2048)
    {
        if (MAX_LINE_CHAR != (len = kfifo_out(&prtFifo, &tmpBuf, MAX_LINE_CHAR)))
        {
            PRT_ERR("kfifo prtFifo out len [%d]\n", len);
        }
        TempObj.pBuf = tmpBuf;        
    }
    else
    {
        if (MAX_LINE_CHAR != (len = kfifo_out2(&prtFifo, MAX_LINE_CHAR)))
        {
            PRT_ERR("kfifo prtFifo out len [%d]\n", len);
        }
    }

kfifo's People

Contributors

houwentao avatar houwentaoff avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.