unsigned int __kfifo_out_peek(struct __kfifo *fifo, void *buf, unsigned int len) { unsigned int l; l = fifo->in - fifo->out; if (len > l) len = l; kfifo_copy_out(fifo, buf, len, fifo->out); return len; } unsigned int __kfifo_out(struct __kfifo *fifo, void *buf, ...
kfifo_copy_out(fifo, buf, len, fifo->out); return len; } EXPORT_SYMBOL(__kfifo_out_peek); unsigned int __kfifo_out(struct __kfifo *fifo, void *buf, unsigned int len) { len = __kfifo_out_peek(fifo, buf, len); fifo->out += len; return len; } EXPORT_SYMBOL(__kfifo_out)...
len = __kfifo_out_peek(fifo, buf, len); fifo->out += len; return len; } EXPORT_SYMBOL(__kfifo_out); 这里多了一个 叫做 __kfifo_out_peek 的函数,该函数只是查看队列出列的那个结构的值,不会真正的取出队列。 队列的判空 队列的判空,主要是看 in 和 out 是否一致,如果一致的话,则说明队列...
unsigned int kfifo_out_locked(struct kfifo *fifo, void *to, unsigned int n, spinlock_t *lock); unsigned int kfifo_out_peek(struct kfifo *fifo, void *to, unsigned int len, unsigned offset); 2)摘取队列数据至用户空间的函数 unsigned int kfifo_to_user(struct kfifo *fifo, void __user *to...
调用kfifo_in 函数将数据加入队列,kfifo_out 将数据从队列中取出并从队列中删除(增加 out 值),Linux 还提供了 kfifo_out_peek 函数从队列中取数据但并不删除(不增加 out 值)。kfifo_in 中会先调用 __kfifo_in_data 将输入加入队列,然后调用 __kfifo_add_in 增加 in 的值,kfifo_out 相反则调用 __kfifo...
在需要的地方从kfifo中读取数据,可以使用kfifo_out()函数。 在需要的地方对数据进行处理,可以使用kfifo_peek()函数来查看kfifo中的数据,或者直接对kfifo中的数据进行操作。 如果需要在中断上下文中使用kfifo,可以使用kfifo_from_user()和kfifo_to_user()函数来在中断上下文中传递数据。 最后,当不再需要使用kfifo时,...
在改变读写指针的时候,应该是原子操作。这要求仅通过读写指针的关系来判断剩余空间长度,而不是用一个变量来记录已使用长度。(更详细解释,可以看这个博主...
extern unsigned int __kfifo_out_peek(struct __kfifo *fifo, void *buf, unsigned int len);extern unsigned int __kfifo_in_r(struct __kfifo *fifo, const void *buf, unsigned int len, size_t recsize);extern unsigned int __kfifo_out_r(struct __kfifo *fifo,...
/** * kfifo_out_peek - gets some data from the fifo * @fifo: address of the fifo to be used * @buf: pointer to the storage buffer * @n: max. number of elements to get * * This macro get the data from the fifo and return the numbers of elements ...
typeof(__tmp->ptr) __dummy __attribute__ ((unused)) = NULL; \ __buf = __dummy; \ } \ (__recsize) ? \ __kfifo_out_peek_r(__kfifo, __buf, __n, __recsize) : \ __kfifo_out_peek(__kfifo, __buf, __n); \2...