由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 给大家出个多进程的题
相关主题
Re: java producer consumer problem (转载)mutex和semaphore的差别到底是什么?
一个JAVA程序请教pthread mutex能不能用与thread和process之间
请教一个concurrentlinkedqueue的用法问题Semaphores in Linux (转载)
请教pthread producer-consumer问题为什么说semaphore是一种进程间的通信方式。
求教一个Java问题 IllegalMonitorStateExceptionMATLAB function call too slow
现在082KAFKA支持produce数组吗大家看过来Re: C++ Guys!!!!
java producer consumer problem (转载)thread, semaphore, 问题。
Kafka consumer启动怎样不读之前的massageRestaurant Reservation System...
相关话题的讨论汇总
话题: consumer话题: consumers话题: each话题: resource话题: producer
进入Programming版参与讨论
1 (共1页)
l*****c
发帖数: 1153
1
今天下午没事编出来个题,呵呵。
Implement a multi-consumer multi-producer model such that:
1. each consumer could consume multiple resources at a time, which means each
consumer must get a given number of resource at once. The interface of the
consumer would look like: void consumer(int n) where n is the number of resource it
needs at once.
2. each producer produces multiple resources, similar like the consumer.
3. The consumers are served on a less-demond-first-serve basis, such that at
each time the consumer
f*******y
发帖数: 988
2
这个题目貌似不太适合interview
看起来没个把个小时搞不出

each
it
at
requires

【在 l*****c 的大作中提到】
: 今天下午没事编出来个题,呵呵。
: Implement a multi-consumer multi-producer model such that:
: 1. each consumer could consume multiple resources at a time, which means each
: consumer must get a given number of resource at once. The interface of the
: consumer would look like: void consumer(int n) where n is the number of resource it
: needs at once.
: 2. each producer produces multiple resources, similar like the consumer.
: 3. The consumers are served on a less-demond-first-serve basis, such that at
: each time the consumer

l*****c
发帖数: 1153
3
我是说这个如果可以搞定,那么interview的题应该不在话下了。

【在 f*******y 的大作中提到】
: 这个题目貌似不太适合interview
: 看起来没个把个小时搞不出
:
: each
: it
: at
: requires

p***o
发帖数: 1252
4
Nice problem. I need as many semaphores as consumers and one lock.
Is there any better solution?
To prove the correctness is also interesting.

each
resource it
at
requires

【在 l*****c 的大作中提到】
: 今天下午没事编出来个题,呵呵。
: Implement a multi-consumer multi-producer model such that:
: 1. each consumer could consume multiple resources at a time, which means each
: consumer must get a given number of resource at once. The interface of the
: consumer would look like: void consumer(int n) where n is the number of resource it
: needs at once.
: 2. each producer produces multiple resources, similar like the consumer.
: 3. The consumers are served on a less-demond-first-serve basis, such that at
: each time the consumer

l*****c
发帖数: 1153
5
The problem is, you don't know how many consumers are there. Actually the
number of consumers might be dynamically changing during the processing.

【在 p***o 的大作中提到】
: Nice problem. I need as many semaphores as consumers and one lock.
: Is there any better solution?
: To prove the correctness is also interesting.
:
: each
: resource it
: at
: requires

p***o
发帖数: 1252
6
That's what I mean ... You create one when entering Consumer( ) and destroy
it when leaving Consumer( ).

【在 l*****c 的大作中提到】
: The problem is, you don't know how many consumers are there. Actually the
: number of consumers might be dynamically changing during the processing.

l*****c
发帖数: 1153
7
OK. I know what you mean. That works. Where is your complete solution? But I
think we only need one semaphore to count the # of consumers, no need to be
one semaphore per consumer.
I have a solution with three semaphores (but I left it at home).

destroy

【在 p***o 的大作中提到】
: That's what I mean ... You create one when entering Consumer( ) and destroy
: it when leaving Consumer( ).

1 (共1页)
进入Programming版参与讨论
相关主题
Restaurant Reservation System...求教一个Java问题 IllegalMonitorStateException
about critical section现在082KAFKA支持produce数组吗
关于multi threadjava producer consumer problem (转载)
how to answer this question, thanksKafka consumer启动怎样不读之前的massage
Re: java producer consumer problem (转载)mutex和semaphore的差别到底是什么?
一个JAVA程序请教pthread mutex能不能用与thread和process之间
请教一个concurrentlinkedqueue的用法问题Semaphores in Linux (转载)
请教pthread producer-consumer问题为什么说semaphore是一种进程间的通信方式。
相关话题的讨论汇总
话题: consumer话题: consumers话题: each话题: resource话题: producer