Re: Problem using thread ??



Did you verify that all your thread run at the priority you set to?

Perhaps you can create a small kernel in where you only setup your IST with
the 10ms and see if this is working.
You can also run kernel tracker to see what is happening inside your kernel.
And what is causing the delay, also build a profiling kernel...

I suspect that a higher priority thread is messing around.

Hope this helps,

Erwin Zwart

"fred_d" <duchassin@xxxxxxxxx> wrote in message
news:frdbt1$aa$1@xxxxxxxxxxxxxxxxxxxxx
Nobody has an idea please ???

Windows CE is a real time OS isn'it ?? Why my 10 ms interrupt with a very
big priority are not ok every 10 ms (even if an other thread has a lot of
work and this thread has a "NORMAL" priority!!)

thanks

"fred_d" <duchassin@xxxxxxxxx> a écrit dans le message de news:
framj1$tsr$1@xxxxxxxxxxxxxxxxxxxxx
Ok so to give more information my program is composed like this:

-my main thread which only give message to the main window :
priority=251.
-a thread INTERRUPT: priority 50.
-a thread MONITOR with a normal priority: priority=251
-a thread Interrupt on GPIO (which occurs only sometimes) and give SPI
dialog: priority=250 (with a waitforsingleobject on GPIO event so i
didn't use CPU if i have no interrupt)
-a second thread Interrupt on GPIO (which occurs only sometimes) and give
SPI dialog: priority=250 (with a waitforsingleobject on GPIO event so i
didn't use CPU if i have no interrupt)
-a thread with serial dialog and a priority=249 with a WaitCOmEvent().

There is a lot of thread because i use a lot of interrupt... But in
normal mode (that's to say when i saw problem), there is only the thread
MONITOR + INTERRUPT which are running.

I saw problem when i have a lot of dialog in my MONITOR thread. For
example i have a do... while boucle with I2C dialog inside and at this
time, i forget to go to 10 ms INTERRUPT whereas he has a priority of 50
!!!

So should i put a priority higher than 50 in interrupt thread???? ( i
tried with priority 10 and it's identical !!!!)

For superclass:

My timer event occurs every 10ms... So it's my explanation (commentary)
which are wrong!!! My time out is 10 seconds but i should never use this
Time_out !!! My interrupt comes because when i do nothing in my monitor i
have 10 ms interrupt. If in the monitor thread i do a lot of I2C dialog,
i lost interrupt and i go to interrupt every 10s or 20 seconds or 30
seconds !!!! It's not a ime out problem but a CPU use problem!!!


Thanks

WaitForSingleObject(g_TimerEvent, /*INFINITE*/10000); //Attente :
Time_Out:1sec

You have here Timeout of 10 seconds, not 1 second. So I assume that your
interrupt never comes, because you claim you are called 10 seconds later.
"Bruce Eitman [eMVP]" <beitman.nospam@xxxxxxxxxxxxxxxxxxxxxx> a écrit
dans le message de news: uuT5CYGhIHA.4880@xxxxxxxxxxxxxxxxxxxxxxx
Okay, that confims that you are actually using an interrupt, I was
suspicious.

You should confirm the thread priorities. Especially since you tell us
that you are running at thread priority NORMAL, that is a term from CE
3.0 that really doesn't apply since then.

Also, is it possible that the low priority thread is doing something
causes a high priority thread in one of your drivers to run? 50 is very
high, but there are 49 priorities higher.

--
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

"fred_d" <duchassin@xxxxxxxxx> wrote in message
news:fr8n38$46n$1@xxxxxxxxxxxxxxxxxxxxx
The interrupt is initialized like this:

pTimerReg = MapRegister(TIMER_BASE);
pTimerReg->omcr5 = OMCRX_C | OMCRX_P | OMCRX_S | OMCRX_R |
OMCRX_CRES_1mS;//match control regsiter
pTimerReg->osmr5 = cDureeITPrimaire; // 10 ms
pTimerReg->oier |= OIER_E5; //interrupt enable E4
pTimerReg->oscr5 = 0x0000; //init à 0


// Create an Event to wait on
g_TimerEvent = CreateEvent(NULL, FALSE, FALSE, NULL);

KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &TimerIrq, sizeof(DWORD),
&g_Timerintr, sizeof(DWORD), NULL);

// Link our Event with the SYSINTR
test = InterruptInitialize(g_Timerintr, g_TimerEvent, NULL, 0);

ThreadIT = CreateThread(NULL, 0, Interrupt10ms, GlobalHwnd,
CREATE_SUSPENDED, NULL);
CeSetThreadPriority(ThreadIT, 50);
ResumeThread(ThreadIT);//pr démarrer la tache //



And the Boucle in the thread interrupt is like this:

DWORD WINAPI Interrupt10ms (LPVOID pParam)
{

while(1)
{

WaitForSingleObject(g_TimerEvent, /*INFINITE*/10000); //Attente :
Time_Out:1sec


if((pTimerReg->ossr & OSSR_M5) == OSSR_M5) //verifie que l'it provienne
bien du bon timer
{
pTimerReg->ossr |= OSSR_M5;

TraiteIT10ms();//-->traitement IT

InterruptDone(g_Timerintr);
}

if(QuitThread) break;

}

ExitThread(WM_QUIT);

return 0;


}

The source of the interrupt is a timer interrupt. I use OS5 timer to
generate an interrupt.

Thanks to help me.

Fred



"Bruce Eitman [eMVP]" <beitman.nospam@xxxxxxxxxxxxxxxxxxxxxx> a écrit
dans le message de news: %23wwaCpEhIHA.5900@xxxxxxxxxxxxxxxxxxxxxxx
How do you define interrupt? What is the source of the interrupt?

--
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

"fred_d" <duchassin@xxxxxxxxx> wrote in message
news:fr8jil$2n3$1@xxxxxxxxxxxxxxxxxxxxx
Hello everybody,

I'm asking for help because i have problem with thread programming!

My application is runing under windows Ce 5. I use evc++ to make my
application.

In fact, my program is composed of 2 threads:
- One main thread which is the core of my application. Everythingh is
done in this thread. --> MAIN thread with priority NORMAL
-A thread which occurs every 10 ms. Every 10 ms, a timer interrupt
occurs and I control if a key is pressed. (if a key is pressed, i
only validate a flag and in the main thread, i do the action desired
by this flag). --> INTERRUPT thread with priority : 50 (high
priority).

So you understand that the thread INTERRUPT wich occurs every 10 ms
is very important.

My problem is the following:
If in the main thread i have a boucle (a do...while for example)
which used a lot of CPU time (this thread has a normal priority).
At this time, I never go to the thread INTERRUPT whereas this thread
has a high priority !!! (sometimes i go in this thread 10 or 20
seconds later !!!)

I don't knwo why !! I just would like to have a periodic interrupt...


Thanks to help me please.

Fred













.