Re: question about thread scheduling



Hi Chris,
thanks for your help!
Zhiqiang
"<ctacke/>" <ctacke[@]opennetcf[dot]com> schrieb im Newsbeitrag
news:%23DKFEqGcHHA.4888@xxxxxxxxxxxxxxxxxxxxxxx
CeSetThreadPriority(GetCurrentThread(), priority);


--
Chris Tacke - Embedded MVP
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--



"Zhiqiang Li" <zhiqiang.li@xxxxxxxxxx> wrote in message
news:%23fkcpiGcHHA.3408@xxxxxxxxxxxxxxxxxxxxxxx
Dear All,
there is any way to change the default priority of the main thread of an
application process?

thanks in advance
Zhiqiang
"Zhiqiang Li" <zhiqiang.li@xxxxxxxxxx> schrieb im Newsbeitrag
news:OBk93KvaHHA.4552@xxxxxxxxxxxxxxxxxxxxxxx
Hi Remi,
I realize that I have misunderstood what you have told me. Actually,
what you provided is the template for my implementation.
thanks a lot for your help!

Zhiqiang
"Remi de Gravelaine" <gravelaine at aton dash sys dot fr> schrieb im
Newsbeitrag news:OHk45G9ZHHA.4520@xxxxxxxxxxxxxxxxxxxxxxx
Zhiqiang,

You should try to tell us *exactly* what you want to do.
You should also avoid multiplying the discussion threads if you want
people to take care of you from the beginning.
If I understood what you want to do, you have implemented a polling
loop to do some job (what kind of job?) every 4ms.
You have put this loop in a high-priority thread started by the
XXX_Init function of a stream driver.
You are using CE 6.0 on a CEPC.

The loop should thus look like:

while (!g_bSuicide)
{
Sleep(3);
<do some job>
}

There is no reason that such a loop exits except when g_bSuicide is set
to TRUE (something that can be done in XXX_Deinit) or the <do some job>
code executes a break of goto intruction.

Now, why Sleep(3) instead of Sleep(4)? Because Sleep(3) will sleep for
*at least* 3 ms and because Sleep is synchonized on timer ticks, that
fire every ms (producing the SYSINTR_RESCHED you are focusing on.) So,
Sleep(3) returns from sleeping right after the third tick and a new 1ms
slice begins. You <do some job> during a portion of this slice and
reenter Sleep(3). Sleep(3) puts your thread to sleep for 3 timer ticks
and that means the time remaining in the current tick + 3 ms.

HTH
Remi









.



Relevant Pages

  • Re: question about thread scheduling
    ... CeSetThreadPriority(GetCurrentThread(), priority); ... Chris Tacke - Embedded MVP ... Managed Code in the Embedded World ... You have put this loop in a high-priority thread started by the XXX_Init ...
    (microsoft.public.windowsce.platbuilder)
  • Re: ArrayList Remove Item
    ... Chris Tacke - Embedded MVP ... Managed Code in the Embedded World ... I want to loop to remove someitem in the ... However, it pops me exception. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: question about thread scheduling
    ... I doubt you will need to mess with the system tick to get what ... I will try what you suggested, the reason that I didn't use the sleep ... If the NN run in a different thread as the control loop ... Sleepputs your thread to sleep for 3 timer ticks and ...
    (microsoft.public.windowsce.platbuilder)
  • Re: question about thread scheduling
    ... whatsoever to tamper with the timer tick. ... If the NN run in a different thread as the control loop ... least* 3 ms and because Sleep is synchonized on timer ticks, ...
    (microsoft.public.windowsce.platbuilder)
  • Re: regression introduced by - timers: fix itimer/many thread hang
    ... Patches exist that implement a dynamically growable percpu pool (using ... doing a for_each_possible_cpuloop on every tick on all cpus isn't ... While I agree that the linear loop is sub-optimal, ... But with your new scheme it'll be a problem regardless of how many ...
    (Linux-Kernel)