Question

I have a shared memory X (array), 2 type of process and I have 3 semaphores, one for modifier X and the other one is for wait until I want to wake up one of these waited process.

Step by step:

1. I'm the process 1 and I ask for semaphore 1 (mutex).
2. OK I got it so I can add me in the array, now I wait (semaphore 2).
3. REPITE this for all the process

Now I have an array with 20 PID's for example, and I want wake up the process 5 (x[4]).

The question is: how can I wake up this process? How can I send a signal to a concret PID?

Excuse my english...

Thank you guys!!

Was it helpful?

Solution

You might use the kill(2) syscall to send a signal to some given process.

I am not sure it is the best way to synchronize (I believe it is not; read signal(7)). You could use Posix semaphores sem_overview(7) (or even old SysV semaphores svipc(7)) or pipes pipe(7) (or unix(7) sockets) with poll(2)

Read Advanced Linux Programming

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top