In the project "Client-Server Communication using IPC and Threads", before the Vendor sends the latest result to the shared memory, the processRequest() function reads the result as if the previous one is still present in the shared memory. Consequently, when processRequest() function sends this outdated result to the message queue, it does not correspond to the current client that initiated the request. As a result, the client fails to receive the actual result from the message queue.
Please provide guidance on how to address and synchronize this issue.
The above issue is resolved by using an additional thread semaphore for handshaking between the Vendor and the processRequest() function. Initially, the processRequest() function remains in a sem_wait state until the Vendor sends the fresh result to the shared memory. As soon as the Vendor shares the updated result in the shared memory, the Vendor changes the thread semaphore state to the sem_post.
It's crucial to initialize the thread semaphore with a value of zero.
After substituting shared memory with a message queue, I am currently facing an issue. The program appears to be in a waiting state, and attempts to send a message from the vendor to the newly created message queue are unsuccessful. Notably, the message send operation does not report any errors. What might be the reason for this behavior?