Re: windows ce 4.2 Sleep function
- From: "Bruce Eitman \(eMVP\)" <beitmannospam@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 12 Sep 2005 12:26:23 -0400
Please define "highest priority" do you mean that the priority is set to
zero? On further review, no that is not what you mean, you mean it is
THREAD_PRIORITY_TIME_CRITICAL which is a very low priority (248 on a scale
of 0-255 with zero being the highest). You need to raise your priority.
--
Bruce Eitman (eMVP)
Senior Engineer
beitman AT applieddata DOT net
Applied Data Systems
www.applieddata.net
An ISO 9001:2000 Registered Company
Microsoft WEP Gold-level Member
"Han" <Han@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:F4A3FD70-0308-454A-ACB3-7347C0589F39@xxxxxxxxxxxxxxxx
>I create a thread as below:
>
> hThread1= CreateThread(NULL,0,Thread2,(PVOID)nParameter,0,&dwThread1ID);
> CeSetThreadPriority(hThread1,THREAD_PRIORITY_TIME_CRITICAL);
> CeSetThreadQuantum(hThread1,0);
>
> DWORD WINAPI Thread2(PVOID pARG)
> {
>
> register long i;
> volatile register long k=0;
> register long j=0;
> register long Maxv=0;
> long tick3=GetTickCount();
> long tick1=0;
> long tick5=0;
> long maxtick=0;
> long tick2=0;
>
>
> for (ii=0;ii<2000;ii++)
> {
> tick1=GetTickCount();
> for(i=0;i<100000;i++)
> {
> k++;
> }
>
> tick2=GetTickCount();
> if ((tick2-tick1)>Maxv)
> {
> Maxv=tick2-tick1;
> }
> Sleep(1);
> tick5=GetTickCount();
>
>
> if( (tick5-tick2)>maxtick)
> maxtick=tick5-tick2;
>
>
> printf("Max:%d Tick:%d Tic2: %d \r",Maxv,tick2-tick1,maxtick);
> }
>
> }
>
> in thread I am running a dummy loop to burn some cpu time, and sleep 1 ms
> to
> let other process do their job. I use tick5 and tick2 variables to check
> the
> return time diff. from sleep. The return time can be as high as 20-30 ms
> under load, or if I move mouse etc. The thread has the highest priority,
> and
> this is real time application which must be response in deterministic time
> around 2-3 ms, how can I do it with CE 4.2?
>
> I also tried to use WaitForSingleObject(thevent,1), I created an event
> which
> is never signalled, WaitForSingleObject is work as expected (timeout) but
> get
> same 20-30 ms delays.
>
> Regards,
.
- References:
- windows ce 4.2 Sleep function
- From: Han
- windows ce 4.2 Sleep function
- Prev by Date: Re: how to got the IWebBrowser2 interface in wince?
- Next by Date: Jpeg to Bitmap
- Previous by thread: windows ce 4.2 Sleep function
- Next by thread: Re: windows ce 4.2 Sleep function
- Index(es):
Relevant Pages
|