Synchronize two processes using two different states

I am trying to develop a way to synchronize two processes sharing data.

Basically, I have two processes related to using shared memory. I need process A to set some data in the shared memory area, and then process B to read that data and act on it.

The sequence of events I am looking for is:

  • B blocks the expected data access.
  • A writes data
  • Available Signal Data Available
  • B reads data
  • B blocks the pending data access signal
  • Signal data not available
  • Everything goes back to the beginning.

In other words, B is blocked until it receives the signal โ€œ1โ€, receives data, and then blocks again until this signal goes to โ€œ0โ€.

, , while, 100% , while , .

, , , . , - .

, , , .

, - , . , .

, ?

+5
4

Linux eventfd(2) , poll/select. eventfd UNIX- fork(2).

0:

, - : "" (setpgid(2)), pid kill(2) sigqueue(2). , Linux signalfd(2) .

+2

2 , , . , . ? ?!

0

linux POSIX (, , -, ) โ€‹โ€‹, , . , , /, , . ..._init .

Linux , "futex", . , , .

0

1
1    . posix semaphore api sem_wait(), , sem_post , .

2 .

1 ()
sem_wait (sem1);
.......
sem_post (sem2);

2 ()
sem_wait (sem2);
.......
sem_post (sem1);

, .

0

All Articles