- 博客(4)
- 资源 (1)
- 收藏
- 关注
原创 linux C 四、进程间通信(有名管道、共享内存、消息队列)
一、有名管道 对应管道文件,可用于任意进程之间进行通信,打开管道时可指定读写方式,通过文件IO操作,内容存放在内存中。 1.1 API #include <unistd.h> #include <fcntl.h> int mkfifo(const char *path, mode_t mode); 成功时返回0,失败时返回EOF path 创建的管道文件路径 mode...
2020-03-25 21:52:42
292
原创 linux C 三、线程
一、线程 基本API(任意一个线程exit会导致整个线程退出) 1.1线程库 pthread 注意:要做同步和互斥 调用API 1)创建线程 pthread_create #include <pthread.h> int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*routine)...
2020-03-24 22:31:24
83
1
原创 linux C 二、进程
一、进程 1.1 fork() 缺点是父子进程执行的是相同的函数,并且执行完 退出的时候需要用 wait()去退出,不然会出现僵尸进程占用 系统资源。 1.2 exec函数族,父进程创建子进程,子进程实现Exec函数 #include <unistd.h> int execl(const char *path, const char *arg, …); int execlp(co...
2020-03-24 22:30:23
80
1
原创 linux C 一、Makefile
一、最简单写法:比如有f1.c f2.c main.c head.h head.h里包含f1.c f2.c , main.c里include head.h 则Makefile最简单写法 test:f1.o f2.o main.o //这里test是执行文件 gcc f1.o f2.o main.o -o test f1.o:f1.c gcc -c f1.c -o f1...
2020-03-24 22:16:46
149
1
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人