Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我目前的任务是关于实现pipe()in Linuxusing shared memory。
pipe()
Linux
因为这是我第一次使用信号量和共享内存(mutex也),所以我对它的经验为零。
mutex
有人可以解释一下它的实施吗?谢谢
从下面的手册页开始:
共享内存
ftok shmget shmat shmctl shmdt
信号量
sem_init sem_wait sem_post
这个想法是,两个不同的应用程序将使用您的管道来交换数据。这可以通过共享内存来完成。还应该进行一些同步(这里是信号量),以确保进程读取的数据是一致的。例如,您必须阻止进程 A 写入管道,直到进程 B 从管道中读取先前写入的数据。