Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Periodic thread scheduling

6 views
Skip to first unread message

R Levels

unread,
Oct 21, 2009, 11:25:01 AM10/21/09
to

For a application were developing we want some (3) threads to run
periodically with a frequency of 100ms with a accuracy as high as possible.
In the past this was a problem but with raising the priority of the threads
to CE_THREAD_PRIO_256_TIME_CRITICAL solved this. With doing this we see a big
increase in scheduling accuracy. About 99,9% of the threads runs are
scheduled in between 100 and 110 ms.

When is look in kernel tracker most threads are scheduled from idle (so we
have cpu power enough). We can do some little stuff in the BSP if needed and
we are the only one running a application on the target.

My question is: Are there any simple things we can do to increase it even
more? I know about interupts and scheduling a ist at a timer interrupt but we
rather not go there.

Bruce Eitman [eMVP]

unread,
Oct 21, 2009, 1:38:54 PM10/21/09
to
Well, you could figure out what actual priority
CE_THREAD_PRIO_256_TIME_CRITICAL is, and notice that it is a fairly low
priority within the system as a whole. Therefore you could use a higher
priority than that.

How are you are you controlling the 100 ms interval? Is that interval
between starting execution, or is it between end and start?

You could change the systems default thread quantum to a smaller value.

--
Bruce Eitman (eMVP)
Senior Engineer
Bruce.Eitman AT EuroTech DOT com
My BLOG http://geekswithblogs.net/bruceeitman

EuroTech Inc.
www.EuroTech.com

"R Levels" <RLe...@discussions.microsoft.com> wrote in message
news:CCF32A83-3FBD-489F...@microsoft.com...

R Levels

unread,
Oct 22, 2009, 3:26:01 AM10/22/09
to
> Well, you could figure out what actual priority
> CE_THREAD_PRIO_256_TIME_CRITICAL is, and notice that it is a fairly low
> priority within the system as a whole. Therefore you could use a higher
> priority than that.

If I'm correct it is 248, we hesitate to go into the drivers area because we
feel applications should stay out of it.



> How are you are you controlling the 100 ms interval? Is that interval
> between starting execution, or is it between end and start?
>

We measure the time the thread starts to work measure when it is finished
(typical after 2-3 ms) and sleep the remaining time (typical 97 ms). So it is
measured between starts.

> You could change the systems default thread quantum to a smaller value.

What effect would that have. First of all we do not consume the entire
quantum of a thread (at least our application we know this for sure). And
because the threads already have a higher priority other application threads
will be pre-empted for the periodic threads to run.

Bruce Eitman [eMVP]

unread,
Oct 22, 2009, 9:34:51 AM10/22/09
to
You seemed to be asking for ways to decrease the latency. So those were my
suggestions.

I should notice that if your code is something like this:

EndTime = GetTickCount();
TimeRemaining = 100 - (EndTime - StartTime);
Sleep( TimeRemaining);

There could be a context switch between any of that and the call to Sleep
which would cuase a delay.

--
Bruce Eitman (eMVP)
Senior Engineer

Bruce.Eitman AT Eurotech DOT com
My BLOG http://geekswithblogs.net/bruceeitman

Eurotech Inc.
www.Eurotech.com

"R Levels" <RLe...@discussions.microsoft.com> wrote in message

news:FDE82B74-F8BC-4622...@microsoft.com...

0 new messages