fifo
linux kernel有链表、队列、映射、二叉树等内建数据结构,并且封装一系列API给linux kernel开发人员使用,本章讲解队列。
base linux-2.6.34
简介
linux kernel 队列 定义如下:
struct kfifo {
unsigned char *buffer; /* the buffer holding the data */
unsigned int size; /* the size of the allocated buffer */
unsigned int in; /* data is added at offset (in % size) */
unsigned int out; /* data is extracted from off. (out % size) */
};如何初始化队列 ?
int kfifo_alloc(struct kfifo *fifo, unsigned int size, gfp_t gfp_mask);如何将数据入队列 ?
unsigned int kfifo_in(struct kfifo *fifo, const void *from, unsigned int len);如何将数据出队列 ?
unsigned int kfifo_out(struct kfifo *fifo, void *to, unsigned int len);如何释放队列 ?
void kfifo_free(struct kfifo *fifo);实践
Last updated
Was this helpful?