Unix下使用信号量的读者作者问题 [英] reader writer problem using semaphore under unix

查看:78
本文介绍了Unix下使用信号量的读者作者问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法解决此问题:
我想设计并实现针对读写器问题的编程解决方案
在UNIX下使用C语言的信号量.
我们假设我们有三个读取器和两个写入器进程可以同时运行.
编写者将更新(写入)到一个内存位置(例如,名为
的整数类型的变量 temp初始化为0).另一方面,读者将阅读temp的内容并显示其
屏幕上的内容以格式化输出.一个作者可以独占访问共享数据
无需其他作者或任何读者在场,而读者可以访问共享的

i can''t reach a solution for this problem :
i want to design and implement a programming solution to the reader-writer problem
using semaphores in C language under UNIX.
We assume that we have three readers and two writers processes that would run concurrently.
A writer is to update (write) into one memory location (let’s say a variable of type integer named
temp initialized to 0). In the other hand, a reader is to read the content of temp and display its
content on the screen in a formatted output. One writer can access the shared data exclusively
without the presence of other writer or any reader, whereas, a reader may access the shared
memory for reading with the presence of other readers (but not writers).

推荐答案

^ ]
我们不为您做功课.如果您无法使用Wikipedia和计算机科学教科书中的伪代码解决方案编写C代码,则最好找到其他研究领域.
http://en.wikipedia.org/wiki/Readers-writers_problem[^]
We don''t do your homework for you. If you can''t write C code from the pseudocode solution found in Wikipedia and computer science textbooks, better find some other area of study.


这篇关于Unix下使用信号量的读者作者问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆