forked from vsamtuc/tinyos3
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkernel_pipe.h
37 lines (27 loc) · 942 Bytes
/
kernel_pipe.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "tinyos.h"
#include "kernel_streams.h"
/* Size of Buffer 16kB*/
#define PIPE_BUFFER_SIZE 16384
/**
@brief Pipe Control Block.
This structure holds all information pertaining to a Pipe.
*/
typedef struct pipe_control_block {
/* Pointers to read/write from buffer*/
FCB *reader, *writer;
/* For blocking writer if no space is available*/
CondVar has_space;
/* For blocking reader until data are available*/
CondVar has_data;
/* Write and Read position in buffer*/
int w_position, r_position;
/* Bounded (cyclic) byte buffer*/
char buffer[PIPE_BUFFER_SIZE];
int word_length;
} Pipe_CB;
Pipe_CB* pipe_init();
int sys_Pipe(pipe_t* pipe);
int pipe_write(void* pipecb_t, const char *buf, unsigned int n);
int pipe_read(void* pipecb_t, char *buf, unsigned int n);
int pipe_writer_close(void* _pipecb);
int pipe_reader_close(void* _pipecb);