I have a scenario where:
1: there is a reader process and a writer process, these processes are communicating through SysV message queue.
2:Writer process is faster than reader process, that is, writer process writes messages in the queue faster than reader process reads a message and empty the queue, for example if I have 8 messages in the queue (single message queue) and reader process is yet to read one message at that time writer process trying to write (msgsnd) the 9th message in the queue.
3: What will happen will any of my message will get overwritten ?
4: or my last or first message in the queue will get overwritten ?
5: or the entire queue will be overwritten ?
6: or else the 9th message will be lost ?
7: How can I make sure that none of these scenario happens and I will not loose any new incoming message and no existing messages will get overwritten ?
8: How can I handle this situation ?
Regards
About point 3, the manpage of msgsnd says
therefore you won't be able to add another message to the queue and you will need to store them somewhere else. If you specified IPC_NOWAIT when you opened the queue, then the message will be lost.