我有一个问题,如何同步两个进程。第一个进程必须创建共享内存,然后等待第二个进程填充共享内存并向第一个进程发出信号。我不知道如何让第一个进程等待。
以下是我的进程的伪代码:
进程1:
create shared memory
create a semaphore
wait for the second process /* this part i dont know how to write */
output the shared memory
步骤2:
get shared memory id
get the semaphore id
wait();
fill the shared memory
signalize();