摘要: #问题 一、问题描述 要求: 1、允许多个读者可以同时对文件执行读操作。 2、只允许一个写者往文件中写信息。 3、任一写者在完成写操作之前不允许其他读者或写者工作。 4、写者执行写操作前,应让已有的读者和写者全部退出。 二、问题分析 读者写者问题最核心的问题是如何处理多个读者可以同时对文件的读操作。 阅读全文
posted @ 2022-11-09 14:39 戴骏 阅读(50) 评论(0) 推荐(0)
摘要: #一、实验截图 修改前 修改后 #二、实验代码 //更改前 #include <stdio.h> #include <pthread.h> #include <stdlib.h> #include <semaphore.h> #define NUM 5 int queue[NUM]; sem_t b 阅读全文
posted @ 2022-11-09 14:06 戴骏 阅读(19) 评论(0) 推荐(0)
摘要: #一、实验截图 #二、实验代码 #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <ctype.h> struct arg_set { char *fname; int count; }; struct arg_ 阅读全文
posted @ 2022-11-09 13:28 戴骏 阅读(27) 评论(0) 推荐(0)