A
Allen
I use a semphore to synchronize memory map file access.
The LogWriter thread writes log messages into the map file.
And the LoggerDaemon thread reads log messages from the map file.
When the LogWriter thread writes log messages with Sleep(5) in the
main loop, it is ok.
By to test extreme situation, I write log messages without sleep. And
there will be some
problems occurs when accessing map file for both writer and reader
sides. For example,
the message count will turn to be negative unexpectedly.
I add printf in the writer loop, the writer will be ok. And add printf
in the reader loop,
the reader will be ok.
Who can tell me some clue to find the solution?
Thank you.
The LogWriter thread writes log messages into the map file.
And the LoggerDaemon thread reads log messages from the map file.
When the LogWriter thread writes log messages with Sleep(5) in the
main loop, it is ok.
By to test extreme situation, I write log messages without sleep. And
there will be some
problems occurs when accessing map file for both writer and reader
sides. For example,
the message count will turn to be negative unexpectedly.
I add printf in the writer loop, the writer will be ok. And add printf
in the reader loop,
the reader will be ok.
Who can tell me some clue to find the solution?
Thank you.