1 |
2014-08-13 12:21 GMT-05:00 Grant Edwards <grant.b.edwards@×××××.com>: |
2 |
> This is not Gentoo specific, and while I'm doing my prototyping and |
3 |
> development on a Gentoo system, the eventual target is not going to be |
4 |
> running Gentoo -- so feel free to ignore this thread or throw things |
5 |
> at me. |
6 |
|
7 |
You're close enough ;) I'll try to answer to the best of my ability, |
8 |
which is admittedly not much. |
9 |
|
10 |
> I'm trying to figure out how to synchronize threads which may be in |
11 |
> different processes. Basically, I want thread A to be able to wake up |
12 |
> any number of other threads B, C, D, ... who are all blocking until A |
13 |
> says "go" (and who may or may not be in other processes). |
14 |
|
15 |
Without knowing what you're doing, this sounds like a bad idea; if you |
16 |
*need* to synchronize threads, why aren't they running in the same process? |
17 |
|
18 |
If it's going to be running on Linux, you can send signals through the |
19 |
kernel's signal API; specifically HUP, USR1, and USR2 might be of |
20 |
interest to you. |
21 |
|
22 |
> A condition variable in shared memory is the closest thing I have |
23 |
> found, and my test applications are working OK (so far). But, I'm |
24 |
> unclear on the purpose of the mutex whose address you pass to |
25 |
> pthread_cond_wait(). |
26 |
|
27 |
I'm too much of a rookie to know how to do this; how are you sharing |
28 |
memory between processes? |
29 |
|
30 |
> The mutex appears to be there to serialize access to some user-defined |
31 |
> variable(s) (outside the condition variable itself) which I don't |
32 |
> have. So all the mutex locking/unlocking and resultant blocking of B, |
33 |
> C, D is just wasted overhead and pointless latency. |
34 |
|
35 |
This is definitely not a task for mutexes, a boolean or signaling would |
36 |
work much better. |
37 |
|
38 |
I'm not sure what exactly you're trying to do, but I hope this helps. If |
39 |
you can be more specific about the relationships between processes, I |
40 |
might be able to help more. |
41 |
|
42 |
Alec |