Resource manager for UART buffers

I am using one resource manager to get the received buffer from UART. In the thread where i am reading it executes after 10ms and requests for the data and NPARTS are 2.
resource manager sends empty buffer if there is no available data. So, I want to optimize it either with blocking call or making the smart use of resource manager.
I am using QNX7.1 version.

I’m unclear on what you are doing. You say you are getting data from the UART. That would mean. you are writing a driver that reads the hardware, but the rest of what you have to say does not sound like that is the case.

You also say “it executes after 10ms”. That sounds like a polling loop. I don’t know why you are using a polling loop. That’s a particularly imature way to do things on an RTOS like QNX. You also say “resource manager sends”. Generally speaking resource manager recieve requests. They might send as part of executing other calls but generally they don’t send to clients.

If what you are doing is writing a resource manager that accumulates input data from a serial port and provides it a client, there would be no sleeping for 10ms. You would get requests and reply to them. If you want you can always reply immediately even when there is no data. You can do this either with the standard I/O call read() or you can write your own message passing interface.

Sorry for that. Let me start all over again.

I have one resource manager which is configured to get the UART Data and which is working fine. Implemented WRITE and READ calls in iocntrl.

I have another process and in that there is one thread which handles the communication with resource manager (this thread runs at 10ms periodicity).
it works fine when there is Receive/Transmit data.

Now, Issue is when there is no Data. The thread from the process i mentioned, keeps on calling the READ part of the resource manager and it gets dummy data. I am ignoring the dummy data.
I sending the data in 2 NPARTS.

I am looking for the option to optimize the communication.I am thinking of two option (but i am not sure how to achieve any of them),

  1. Block the thread which calls the resource manager to read the data.
  2. Configuring the NPARTS in such a way that it will not receive the dummy calls like send the size first.

So you have 1 thread that reads/writes to your resource manager and it currently loops at 10ms intervals. Presumably something like:

While (1)
    read(); // Read from resource manager. If you got valid data, process it otherwise do nothing
    send(); // Send data to resource manager

If this is how its done, then to get rid of the 10 ms loop, you should look at the select() call.


Tim is correct that you can probably use select(). I say probably because your RM might not have been written to support it.

If you can modify the RM, why not have a blocking read? If you want you can even have a timeout.

I still don’t know if you are supporting your read and write with standard I/O calls. Whether or not, I don’t know why you are returning dummy data. You can reply indicating that there was ZERO data.