Rev 9725 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9725 | Rev 9766 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
2 | * This is an example program for sending a message through a "pipe". |
2 | * This is an example program for sending a message through a "pipe". |
3 | * Created by turbocat (Maxim Logaev) 2022. |
3 | * Created by turbocat (Maxim Logaev) 2022. |
4 | */ |
4 | */ |
Line 5... | Line 5... | ||
5 | 5 | ||
6 | #include |
6 | #include |
7 | #include |
7 | #include |
8 | #include |
- | |
9 | #include |
8 | #include |
- | 9 | #include |
|
Line 10... | Line 10... | ||
10 | #include |
10 | #include |
11 | 11 | ||
Line 12... | Line 12... | ||
12 | #define TH_STACK_SIZE 1024 |
12 | #define TH_STACK_SIZE 1024 |
13 | #define MESSAGE_SIZE 12 |
13 | #define MESSAGE_SIZE 12 |
14 | 14 | ||
Line 15... | Line 15... | ||
15 | ksys_colors_table_t sys_colors; |
15 | ksys_colors_table_t sys_colors; |
- | 16 | int pipefd[2]; |
|
16 | int pipefd[2]; |
17 | char* send_message = "HELLO PIPE!"; |
17 | char *send_message = "HELLO PIPE!"; |
18 | |
18 | 19 | void tmain() |
|
19 | void tmain() { |
20 | { |
20 | char recv_message[MESSAGE_SIZE]; |
21 | char recv_message[MESSAGE_SIZE]; |
21 | _ksys_posix_read(pipefd[0], recv_message, MESSAGE_SIZE); |
22 | _ksys_posix_read(pipefd[0], recv_message, MESSAGE_SIZE); |
22 | printf("RECV: %s\n", recv_message); |
23 | printf("RECV: %s\n", recv_message); |
Line 23... | Line 24... | ||
23 | assert(!strcmp(recv_message, send_message)); |
24 | assert(!strcmp(recv_message, send_message)); |
- | 25 | puts("Successful pipe test"); |
|
24 | puts("Successful pipe test"); |
26 | exit(0); |
25 | exit(0); |
27 | } |
26 | } |
28 | |
27 | 29 | void create_thread(void) |
|
28 | void create_thread(void){ |
30 | { |
Line 38... | Line 40... | ||
38 | return; |
40 | return; |
39 | } |
41 | } |
40 | printf("New thread created (TID=%u)\n", tid); |
42 | printf("New thread created (TID=%u)\n", tid); |
41 | } |
43 | } |
Line 42... | Line 44... | ||
42 | 44 | ||
- | 45 | void main() |
|
43 | void main() { |
46 | { |
44 | if (_ksys_posix_pipe2(pipefd, 0)) { |
47 | if (_ksys_posix_pipe2(pipefd, 0)) { |
45 | puts("Pipe creation error!"); |
48 | puts("Pipe creation error!"); |
46 | return; |
49 | return; |
47 | } |
50 | } |