Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.arch.embedded > #25487
| From | Don Y <blockedofcourse@foo.invalid> |
|---|---|
| Newsgroups | comp.arch.embedded |
| Subject | Re: soft real-time on linux |
| Date | 2016-11-12 13:53 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <o07vf8$6f1$1@dont-email.me> (permalink) |
| References | <87eg2gerei.fsf@digitalsignallabs.com> |
On 11/12/2016 6:53 AM, Randy Yates wrote: > 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: > > 1. Switch to the real-time kernel. > > 2. Write our own interrupt handler/driver. > > I'm not very confident as to which direction to go. Any input would be > appreciated. If you don't want to rely on timeliness guarantees from the software, then rely on those implicit in the hardware. I.e., build a layer in front of the existing RxISR that operates a trivial state machine that does your PFM recognition. You *know* that the Rx ISR will be serviced before N characters have been received, at maximum bit rate (otherwise characters are dropped and your application has bigger problems to address, needs faster hardware, a re-tooling of the rest of the system tasks, etc.) so that gives you an upper bound on the latency incurred by your modified ISR. This has the advantage of being somewhat portable (to different OS's, different versions of the OS, different hardware capabilities, etc.). And, as you're not doing ALL of your protocol handling/decoding in the ISR, it's not as brittle as it would be, otherwise. [It's akin to decoding XON/XOFF characters (a two bit FSM) in the Rx ISR because the latency involved in doing it in userland would make it impractical]
Back to comp.arch.embedded | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
soft real-time on linux Randy Yates <yates@digitalsignallabs.com> - 2016-11-12 08:53 -0500
Re: soft real-time on linux Grant Edwards <invalid@invalid.invalid> - 2016-11-12 17:16 +0000
Re: soft real-time on linux Mel Wilson <mwilson@the-wire.com> - 2016-11-12 17:33 +0000
Re: soft real-time on linux upsidedown@downunder.com - 2016-11-12 20:34 +0200
Re: soft real-time on linux Don Y <blockedofcourse@foo.invalid> - 2016-11-12 13:53 -0700
Re: soft real-time on linux sbattazzo@gmail.com - 2017-02-09 11:06 -0800
Re: soft real-time on linux Paul Rubin <no.email@nospam.invalid> - 2016-11-12 14:12 -0800
Re: soft real-time on linux Phil Hobbs <pcdhSpamMeSenseless@electrooptical.net> - 2017-02-08 21:17 -0500
Re: soft real-time on linux Jack <jack4747@gmail.com> - 2017-02-09 00:16 -0800
Re: soft real-time on linux David Brown <david.brown@hesbynett.no> - 2017-02-09 10:00 +0100
Re: soft real-time on linux Phil Hobbs <pcdhSpamMeSenseless@electrooptical.net> - 2017-02-10 11:12 -0500
Re: soft real-time on linux George Neuner <gneuner2@comcast.net> - 2017-02-11 01:33 -0500
Re: soft real-time on linux Phil Hobbs <pcdhSpamMeSenseless@electrooptical.net> - 2017-02-10 22:10 -0500
csiph-web