Non-Blocking read() in C

Hello everybody,

I am trying to read data from an SD card. But the library function of read() is in blocking mode (synchronous). I want to modify this function into non-blocking mode (asynchronous) as it is waste of time waiting for the read operation to complete and I have to do other tasks as well. Its in C.

Some ideas are to use threading or else. Can anybody give his/her thoughts.

Any tips and ideas on how to do it.

Thank you in advance

It seems you got your answer - http://forums.devshed.com/c-programming-42/non-blocking-read-in-c-932747.html

1 Like

Hi,

Take a look at the select system call in C. I do not know how to read data from the SD card. However I faced a similar problem when I was working on a project where I had to display GUI and scan the incoming packets from the network.

Search for Beejs Network programming tutorial. there you will find a very good tutorial about how to use the select system call. In case the select system call doesnt find data on a particular port( I/O or Network) , it simply continues and doesnt block (asynchronous read).