问题描述
我遇到了很大的问题,因为我需要做我的整个教师教育所依赖的任务.如果我不这样做,我将离开教职人员,所以我求你或某人帮助我做到这一点.
作业如下:
模拟一个具有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
推荐答案
这篇关于C,C ++生产者使用者遇到共享缓冲区问题... PLZ帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!