摘要: 代码: #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <ctype.h> struct arg_set { char *fname; int count; }; struct arg_set *mailbox 阅读全文
posted @ 2022-11-13 22:12 20201330马榕辰 阅读(10) 评论(0) 推荐(0) 编辑
摘要: 代码: #include <stdio.h> #include <pthread.h> #include <stdlib.h> #include <semaphore.h> #define NUM 5 int queue[NUM]; sem_t blank_number, product_numbe 阅读全文
posted @ 2022-11-13 22:00 20201330马榕辰 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 一、同步互斥问题 - 读者写者问题之写者优先 (一)问题要求 抽象解释:多个进程访问一个共享的数据区 读者(读进程)只能读数据,写者(写进程)只能写数据 适用于数据库、文件、内存、寄存器等数据区的访问模型 如12306购票系统,由于用户量庞大和数据量巨大,不可避免地会出现多个进程同时查询(读)或修改 阅读全文
posted @ 2022-11-13 21:44 20201330马榕辰 阅读(49) 评论(0) 推荐(0) 编辑