2020年2月9日

c 消费者生产者V2

摘要: 增加了buffsize,生产者生产过多,wait #include <stdio.h> #include <unistd.h> #include <pthread.h> #define PRODUCER_SIZE 1 #define CONSUMER_SIZE 1 int products = 0; 阅读全文

posted @ 2020-02-09 14:48 luckygxf 阅读(162) 评论(0) 推荐(0) 编辑

c 生产者消费者V1

摘要: 1. 生产者1个线程 2. 消费者1个线程 3. 通过pthread_mutex_t并发控制 4. 通过pthread_cond_t wait signal 5. signal放到unlock后面 6. sleep放到unlock后面 #include <stdio.h> #include <uni 阅读全文

posted @ 2020-02-09 14:38 luckygxf 阅读(355) 评论(0) 推荐(0) 编辑

c多进程

摘要: 1. fork创建子进程 2. wait等待子进程结束 #include <stdio.h> #include <unistd.h> #include <sys/wait.h> int main() { int count = 0; int pid = fork(); if (pid == 0) { 阅读全文

posted @ 2020-02-09 11:40 luckygxf 阅读(343) 评论(0) 推荐(0) 编辑

c读写文件

摘要: #include <stdio.h> #include <unistd.h> #include <pthread.h> #include <stdlib.h> #include <string.h> char *fileName = "/Users/gxf/CLionProjects/untitle 阅读全文

posted @ 2020-02-09 11:27 luckygxf 阅读(138) 评论(0) 推荐(0) 编辑

导航