Hello All,
I have a requirement to port the MSTP physical layer (basically RS-485) of the BACnet protocol stack to linux. The protocol requires certain timing to be met, for example, the response to a "Poll For Master" must be less than 20 milliseconds.
In order to develop this in as short an amount of time, I'd like to use simple threads and read()/write() commands. However, the standard linux kernel is not real-time, so any thread could be blocked for an unknown amount of time. Thus for example a thread that is listening for a "Poll For Master" packet might not run for more than 20 milliseconds after the packet was received, thus missing the poll.
But missing a poll is not the end of the world. Eventually (and fairly quickly) another PFM will be sent out and the device would have another chance to respond.
Let us also presume such is the case for other response/time violations throughout the protocol.
The question is, could such an application be written that was "close enough to real-time" on a standard (non-real-time) kernel?
I was told by someone on the ##kernel channel that if the kernel is compiled with "preemptive" enabled, there is a way to set a thread's priority to "real-time" and it will not only have priority over other user-land threads but also will preempt much of the kernel's internal threads. This sounds promising.
If this isn't "good enough" (which is not really well-defined at this point), there are two alternatives that I can think of:
- Switch to the real-time kernel.
- Write our own interrupt handler/driver.
I'm not very confident as to which direction to go. Any input would be appreciated.