I have to share serial port read function with two other functions, basically
-
first function keeps polling on serial port read function for data every 1000 msec
-
when something is written to serial port , it has to read back ack/nack from serial port.
Can anyone suggest how this synchronization can be achieved efficiently with mutex or any other synchronization functionality available in linux for common read function? I am not using any threads for these operation since this is done on polling basis.
Just disable the polling while you wait for ack. You don’t need a mutex because you’re not using a thread, just use a global variable set by the writing function and read by the polling, so that you know if you have to skip polling.