C,C ++生产者使用者遇到共享缓冲区问题... PLZ帮助 [英] c, c++ producer consumer with shared buffer problem...plz help

查看:60
本文介绍了C,C ++生产者使用者遇到共享缓冲区问题... PLZ帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我遇到了很大的问题,因为我需要做我的整个教师教育所依赖的任务.如果我不这样做,我将离开教职人员,所以我求你或某人帮助我做到这一点.

作业如下:

模拟一个具有m个生产者和n个消费者的系统,这些生产者和n个消费者通过k个字符长度的缓冲区(它是共享缓冲区)进行通信.生产者首先从键盘加载字符串,只有在所有m个生产者都加载了键盘字符串之后,他们才可以开始将字符(一个字符而不是整个字符串)发送到缓冲区中,然后消费者逐个获取字符从缓冲区.每个生产者在发送一个字符后都会等待随机的秒数/毫秒,然后再尝试发送下一个字符. (范围模式由0到1500ms分别确定)输入数字m,n和k作为命令行参数.每个生产者和消费者都有一个过程进行模拟.在所有生产者都从键盘加载其字符串之前,没有任何生产者可以启动.该部分的同步是通过信号量完成的.生产者和消费者的字符交换同步也需要使用信号量.我需要以适当的方式显示发送和接收字符.实现用于UNIX(Linux)和Windows操作系统的程序.

提前tnx

Hi,

I am in a BIG problem because i need to do an assignment upon which my whole faculty education depends. if i dont do it i''m off from the faculty so i beg you or someone to help me do it.

The assignment goes like this:

Simulate a system with m producers and n consumers who communicate through the buffer (it is shared buffer) of k character length. producers first load the string from the keyboard, and only after all the m producers loaded their keyboard strings, can they begin to send characters (one char not whole string) in to the buffer, and then consumers take char''s one by one from the buffer. Each producer after sending one character waits a random number of seconds / milliseconds before attempting to send the next character. (Range mode as determined independently from 0 to 1500ms) The numbers m,n and k are entered as command line parameters. Each producer and consumer is simulated with a process. None of the producers can start until all producers load their string from the keyboard. Synchronization of that part is done with semaphores. Synchronization of the character exchange of producers and consumers also also needs to be done with semaphores. i need to display in the appropriate way the sending and receiving characters. Achieve program for UNIX (Linux) and Windows operating systems.

tnx in advance

推荐答案

此消息仅在昨天传达给您-即时通知?您缺乏这样做的知识吗?您是否尝试过某事?

如果这是一个大问题,那么您应该早就采取一些行动.您已经发布了项目大纲.首先,它不适合作为快速问答.

第二,
这是询问者的期望:
1. 先尝试您要做什么!
2.制定看起来像问题/无法解决的问题.

试试看,告诉他们是否遇到问题.
成员将非常乐于提供这样的帮助.
Was this conveyed to you yesterday only - Short notice? Do you lack knowledge to do so? Did you tried something?

If this was such a big issue then you should have taken some action long back. You have posted your project outline. First of all it would not fit in here as a Quick Q&A.

Second,
Here is what is expected by enquirers:
1. TRY first what you want to do!
2. Formulate what was done by you that looks like an issue/not working.

Try them and tell if you face issues.
Members will be more than happy to help like this.


好吧,我认为要求非常明确.
您所需要的只是一堆技术知识和开始编码.
生产者-消费者问题是众所周知的,因此您可能会发现很多信息.
祝你好运!
:)
Well, I think the requirements are very, very well stated.
All that you need is a bunch of technical knowledge and start coding.
The producer-consumer problem is very well know, thus you may find a lot of info around.
Good luck and enjoy!
:)


这篇关于C,C ++生产者使用者遇到共享缓冲区问题... PLZ帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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