realtime scheduling

Hi,

I’m doing real time control. The control performance highly depends on the
how accuratly in given time it runs.
The function should run exctly every other mili second. Is it possible to
run the thread in that accuracy of time?

What is the minimum resolution of time for scheduling?

Thanks,

JinWoo

“Jin-Woo Lee” <jl206@cornell.edu> wrote in news:a6rirv$74i$1@inn.qnx.com:

I’m doing real time control. The control performance highly depends on
the how accuratly in given time it runs.
The function should run exctly every other mili second. Is it possible
to run the thread in that accuracy of time?
What is the minimum resolution of time for scheduling?

Could you do the work (or some of it) in an interrupt handler? The only
issue with doing work in a thread, is that it can be scheduled out if
someone of a higher priority becomes ready.

\

Cheers,
Adam

QNX Software Systems Ltd.
[ amallory@qnx.com ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <pschon@baste.magibox.net>

Jin-Woo Lee wrote:

Hi,

I’m doing real time control. The control performance highly depends on the
how accuratly in given time it runs.
The function should run exctly every other mili second. Is it possible to
run the thread in that accuracy of time?

Yes … use the RTC (IRQ8) to create a clock interrupt every 0.999…
millisecond and let your task wait for the puls of the interrup handler.

What is the minimum resolution of time for scheduling?

Scheduling isn’t time driven … it is event driven.

Armin

Thanks for the answer! More questions!

  1. If I need to implement a thread driven by time, what is the time
    resolution?
    For example, is it possible to implement a thread to wake up at every
    1usec?

  2. I heard that the CPU timer is more precise than the hardware timer(IRQ8
    ?). Can I use it to create a time driven thread?

Thanks,
Jinwoo

“Armin Steinhoff” <a-steinhoff@web_.de> wrote in message
news:3C923625.FE0AA960@web_.de…

Jin-Woo Lee wrote:

Hi,

I’m doing real time control. The control performance highly depends on
the
how accuratly in given time it runs.
The function should run exctly every other mili second. Is it possible
to
run the thread in that accuracy of time?

Yes … use the RTC (IRQ8) to create a clock interrupt every 0.999…
millisecond and let your task wait for the puls of the interrup handler.

What is the minimum resolution of time for scheduling?

Scheduling isn’t time driven … it is event driven.

Armin

“Jin-Woo Lee” <jl206@cornell.edu> wrote in news:a77mfd$qb4$1@inn.qnx.com:

  1. If I need to implement a thread driven by time, what is the time
    resolution?
    For example, is it possible to implement a thread to wake up at every
    1usec?

Scheduling is event driven. You could setup a thread to be woken up at
certain time intervals, but you still have the problem of that thread not
being scheduled to run (or could be preempted) if its priority isn’t high
enough (ie. a higher priority thread wants to run). This is why I asked if
you could do the work in an interrupt handler, it would only be preempted
by a higher priority interrupt.

  1. I heard that the CPU timer is more precise than the hardware
    timer(IRQ8 ?). Can I use it to create a time driven thread?

Do you mean the free running counter on the x86? It’s precise, but it
wraps around, and it’s speed is dependant on the CPU type.




\

Cheers,
Adam

QNX Software Systems Ltd.
[ amallory@qnx.com ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <pschon@baste.magibox.net>

O.k. the timer interrupt seems to be the way to go in my situation.Then,
what is the resolution of the timer?

By the way, how many timer can generate the interrupt signal? What I
understand is that the hardware timer(implemented by 8254 chip) generates
IRQ8. Does the free running timer on x86 generate interrupt signal?

Thanks,

JinWoo









“Adam Mallory” <amallory@qnx.com> wrote in message
news:Xns91D675815AB4Damalloryqnxcom@209.226.137.4

“Jin-Woo Lee” <> jl206@cornell.edu> > wrote in news:a77mfd$qb4$> 1@inn.qnx.com> :

  1. If I need to implement a thread driven by time, what is the time
    resolution?
    For example, is it possible to implement a thread to wake up at every
    1usec?

Scheduling is event driven. You could setup a thread to be woken up at
certain time intervals, but you still have the problem of that thread not
being scheduled to run (or could be preempted) if its priority isn’t high
enough (ie. a higher priority thread wants to run). This is why I asked
if
you could do the work in an interrupt handler, it would only be preempted
by a higher priority interrupt.

  1. I heard that the CPU timer is more precise than the hardware
    timer(IRQ8 ?). Can I use it to create a time driven thread?

Do you mean the free running counter on the x86? It’s precise, but it
wraps around, and it’s speed is dependant on the CPU type.




\

Cheers,
Adam

QNX Software Systems Ltd.
[ > amallory@qnx.com > ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <> pschon@baste.magibox.net

“Jin-Woo Lee” <jl206@cornell.edu> wrote in news:a77ris$jn$1@inn.qnx.com:

O.k. the timer interrupt seems to be the way to go in my
situation.Then, what is the resolution of the timer?

Which timer, the IRQ8 generated RTC alarm or a vanilla timer - Take a look
at the documenation on ClockPeriod() and the timers sections. There is a
great overview including timer resolutions, limits, jitter etc.

By the way, how many timer can generate the interrupt signal? What I
understand is that the hardware timer(implemented by 8254 chip)
generates IRQ8. Does the free running timer on x86 generate interrupt
signal?

The RTC clock generates an IRQ8 on the x86, this is the MC146818. The 8254
generates IRQ0 for timer 0, and the other counters are tied to other lines
(speaker etc AFAIK).

The free running timer does not generate an interrupt. The 8254 has 3
counters in it w/ multiple modes. Take a look at the docs for the 8254
or the MC146818 for more information on programming it.



\

Cheers,
Adam

QNX Software Systems Ltd.
[ amallory@qnx.com ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <pschon@baste.magibox.net>