문제

It's a simple question but I can't wrap my head around a solution. I am running a program that is using shared memory. All it needs to do is check if there is new input in the shared memory location and then print out that string. It runs on an infinite loop and will only print out when there is new input.

I'm having trouble writing the IF condition which checks if a new string has been set.

Any help would be grateful. Thanks

도움이 되었습니까?

해결책

You'll typically have a semaphore in addition to your shared memory. The process that writes to the shared memory sets the semaphore after writing data into the shared memory. The other process waits on the semaphore, and reads the data when the semaphore indicates that data is available. See sem_open, sem_wait, sem_post, and sem_close

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top