Re: Problem using thread ??
- From: "fred_d" <duchassin@xxxxxxxxx>
- Date: Fri, 14 Mar 2008 14:27:34 +0100
Hi,
I'm quite disappointed : Maybe i make a mistake in my code or i don't
understand something !
But I think it cames from the interrupt configuration. Indeed, using
gettickcount() api i saw that many times, i enter in my interrupt on
time_out (time_out=1sec). So i reduce the time_out delay to 12 ms and after
it works better.
Maybe it help you to see better the problem. I'm certainely wrong in my
code! (with the interrupt configuration). To my mind, i should forget or
lost interrupt and after i go to interrupt on time_out event!!
Have you seen a problem in the interrupt OS timer configuration ?????
I should make a mistake in the interrupt event, or in the ISR ????
I use pxa270.
Thanks a lot for your time...
Fred
"Bruce Eitman [eMVP]" <beitman.nospam@xxxxxxxxxxxxxxxxxxxxxx> a écrit dans
le message de news: ucpjnLdhIHA.5900@xxxxxxxxxxxxxxxxxxxxxxx
Fred:
This usually indicates that there is something wrong with your code or
your understanding of the problem. This is the kind of thing that can go
on for days, and then one day you will post that you solved it by fixing
your code. It could even be something as simple as your check to see if
the interrupt bit is set, that should have been done in your ISR, so you
don't need to do it there. The ISR could be clearing it.
--
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: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
.
- Follow-Ups:
- Re: Problem using thread ??
- From: Bruce Eitman [eMVP]
- Re: Problem using thread ??
- References:
- Problem using thread ??
- From: fred_d
- Re: Problem using thread ??
- From: Bruce Eitman [eMVP]
- Re: Problem using thread ??
- From: fred_d
- Re: Problem using thread ??
- From: Bruce Eitman [eMVP]
- Re: Problem using thread ??
- From: fred_d
- Re: Problem using thread ??
- From: fred_d
- Re: Problem using thread ??
- From: Bruce Eitman [eMVP]
- Problem using thread ??
- Prev by Date: Re: Problem using thread ??
- Next by Date: Re: Problem using thread ??
- Previous by thread: Re: Problem using thread ??
- Next by thread: Re: Problem using thread ??
- Index(es):
Loading