Re: question about thread scheduling



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
    ... Chris Tacke - Embedded MVP ... Managed Code in the Embedded World ... You have put this loop in a high-priority thread started by the ... Sleepreturns from sleeping right after the third tick and a new 1ms ...
    (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: MVS 4 minute outage
    ... I would suggest that some very high priority task got in a loop - something that runs at dispatching priority x'FF'. ... By 'outage', I mean we could not communicate with MVS through TSO or the ... Search the archives at http://bama.ua.edu/archives/ibm-main.html ...
    (bit.listserv.ibm-main)
  • Re: Wiseman and McGhie are Ranting Again
    ... of which is the clock tick that expires a time slice interval. ... > Then we can start playing around with Thread Priority. ... I think you are comparing pre-emptive and co-operative scheduling. ... then falls quiet and calls its Idle Loop. ...
    (microsoft.public.mac.office.word)
  • Re: Why RosAsm Breaks on a large number of symbols
    ... Are you sure you have not fallen off your pirch again? ... highers priority to the app with that loop you lock up the box. ... Where you have commented about the installation speed of the MASM32 ...
    (alt.lang.asm)