由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - multithread 的semaphore问题
相关主题
大家看过来Re: C++ Guys!!!!Windows XP与Multithreading Programming
mutex和semaphore的差别到底是什么?Pthread support on Windows XP
谁能推荐一个read-writer lock的C++实现? (转载)请教c++ multithreading入门问题
Multi-thread可以mutex锁资源,Multi-process怎么锁资源?thread, semaphore, 问题。
multithread synchronizationRestaurant Reservation System...
给大家出个多进程的题about critical section
Semaphores in Linux (转载)关于multi thread
为什么说semaphore是一种进程间的通信方式。how to answer this question, thanks
相关话题的讨论汇总
话题: semaphore话题: acqure话题: foo话题: release
进入Programming版参与讨论
1 (共1页)
z****e
发帖数: 2024
1
请问如下这个问题是怎么解决的?
看不懂。用mutex好像不行。也不知道semaphore怎么工作的。
Suppose we have the following code to use class Foo. We do not know how the threads will be scheduled in the OS.
question:
Can you design a mechanism to make sure that all the methods will be executed in sequence?
Foo f;
f.A(.....);
f.B(.....);
f.C(.....);
f.A(.....);
f.B(.....);
f.C(.....);
solution:
Semaphore s_a(0);
Semaphore s_b(0);
Semaphore s_c(1);
A {
s_c.acqure(1);
/***/
s_a.release(1);
}
B {
s_a.acqure(1);
/****/
s_b.release(1);
}
C {
s
y***d
发帖数: 2330
2
what is the question of the ultima answer?

the

【在 z****e 的大作中提到】
: 请问如下这个问题是怎么解决的?
: 看不懂。用mutex好像不行。也不知道semaphore怎么工作的。
: Suppose we have the following code to use class Foo. We do not know how the threads will be scheduled in the OS.
: question:
: Can you design a mechanism to make sure that all the methods will be executed in sequence?
: Foo f;
: f.A(.....);
: f.B(.....);
: f.C(.....);
: f.A(.....);

z****e
发帖数: 2024
3
不好意思,题没贴全,补上了,就是按照那几个函数call的顺序call。

【在 y***d 的大作中提到】
: what is the question of the ultima answer?
:
: the

1 (共1页)
进入Programming版参与讨论
相关主题
how to answer this question, thanksmultithread synchronization
你们觉得《the little book of semaphore》这本书怎么样?给大家出个多进程的题
多个thread的通信Semaphores in Linux (转载)
critical section semaphore muta的问题为什么说semaphore是一种进程间的通信方式。
大家看过来Re: C++ Guys!!!!Windows XP与Multithreading Programming
mutex和semaphore的差别到底是什么?Pthread support on Windows XP
谁能推荐一个read-writer lock的C++实现? (转载)请教c++ multithreading入门问题
Multi-thread可以mutex锁资源,Multi-process怎么锁资源?thread, semaphore, 问题。
相关话题的讨论汇总
话题: semaphore话题: acqure话题: foo话题: release