writefifo.c 1 #include <stdio.h> 2 #include <sys/types.h> 3 #include <stdlib.h> 4 5int main (void) 6{ 7 FILE out file; 8 9 if ((out file=fopen ("myfifo","w"))==NULL) 10 { 11 perror("open fifo error"); 12 exit(1); } 14 5 fwrite("you are welcome\n",1,20,out file); 16 fclose(out file); return 0; 18} 式系统实验室 19 D SYSTEM LABORATORY 百ZHDU INSTITUTE FOR AOVANCED5Ue¥OFU5TD
2023/7/14 Linux OS analysis 12/39 writefifo.c
readfifo.c 1 #include <stdio.h> 2 #include <sys/types.h> 3#include <stdlib,h> 4 5int main(void) 6{ 7 FILE in file; 8 int count=0; 9 char buf [20]; 10 if ((in file=fopen ("myfifo","r"))<0) 11 { 12 perror("open fifo for read error"); 13 exit(1); 14 } 15 16 while(count==0) 17 count=fread(buf,1,20,in file); 18 printf("号s",buf)i 19 fclose(in file); 20 return 0; 21} 系统实验室 22 SYSTEM LABORATORY FOR AOVANCED DTUOY OF USTC
2023/7/14 Linux OS analysis 13/39 readfifo.c
2、消息队列 必消息队列就是一个消息的链表。 冬可以把消息看作一个记录,具有特定的格式以及 特定的优先级。 冬对消息队列有写权限的进程可以按照一定的规则 向消息队列添加新消息; 对消息队列有读权限的进程则可以从消息队列中 读走消息。 cience and Techil 嵌入式系统实验室 2023/7/14 Linux OS analysis 14/39 EMBEDDED SYSTEM LABORATORY 5uE料DUN0 ITUTE FOR AOVANCED5 FUOY OF U百TD
2023/7/14 Linux OS analysis 14/39 2、消息队列 ❖消息队列就是一个消息的链表。 ❖可以把消息看作一个记录,具有特定的格式以及 特定的优先级。 ❖对消息队列有写权限的进程可以按照一定的规则 向消息队列添加新消息; 对消息队列有读权限的进程则可以从消息队列中 读走消息