Tenok
A Linux-like Real-Time Operating System for Robotics and Internet of Things
pipe.h
Go to the documentation of this file.
1 
4 #ifndef __KERNEL_PIPE_H__
5 #define __KERNEL_PIPE_H__
6 
7 #include <stdbool.h>
8 #include <stdio.h>
9 
10 #include <fs/fs.h>
11 #include <kernel/kfifo.h>
12 
13 struct pipe {
14  struct kfifo *fifo;
15  struct file file;
16  struct list_head r_wait_list;
17  struct list_head w_wait_list;
18  /* A pipe of POSIX carries a stream between two descriptors: a read of one
19  * takes what is there rather than waiting for the whole request, and finds
20  * the end of the stream once the last writer has gone. The pipes the
21  * kernel exchanges whole messages through do neither.
22  */
23  bool stream;
24  /* The descriptors that name a stream are what keep it alive */
25  unsigned readers;
26  unsigned writers;
27 };
28 
29 struct file *fifo_init(struct inode *file_inode, struct pipe *pipe);
30 ssize_t fifo_read(struct file *filp, char *buf, size_t size, off_t offset);
31 ssize_t fifo_write(struct file *filp,
32  const char *buf,
33  size_t size,
34  off_t offset);
35 
36 struct file *pipe_alloc(void);
37 bool file_is_pipe(struct file *filp);
38 void pipe_release(struct file *filp);
39 void pipe_take(struct file *filp, bool writer);
40 void pipe_give_up(struct file *filp, bool writer);
41 
42 #endif
Definition: fs.h:136
Definition: fs.h:97
Definition: kfifo.h:11
Definition: list.h:111
Definition: pipe.h:13