This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
RE: cyg_thread_delay problem?
- From: =?big5?b?IldhbmcsIEFsdmluICik/al22XkgVEFPKSI=?= <Wang dot Alvin at inventec dot com>
- To: <ecos-discuss at sources dot redhat dot com>
- Date: Fri, 19 Sep 2003 11:30:09 +0800
- Subject: [ECOS] RE: cyg_thread_delay problem?
Hi to all,
I trace cyg_thread_delay() function further, I find that the delay variable is missing when call set_timer.
Set_timer is a inline function as below. When call self()->timer.initialize(trigger), the parameter trigger is zero.
So the alarm function is called and current thread return to running state.
So I think if it's a complier problem. I use gcc3.2.1 as complier. Is there any possible reason that causes this problem.
inline void Cyg_Thread::set_timer(
cyg_tick_count trigger,
cyg_reason reason
)
{
#ifdef CYGFUN_KERNEL_THREADS_TIMER
self()->sleep_reason = reason;
self()->wake_reason = NONE;
self()->timer.initialize( trigger);
#endif
}
void
Cyg_Thread::delay( cyg_tick_count delay)
{
CYG_REPORT_FUNCTION();
CYG_INSTRUMENT_THREAD(DELAY,this,delay);
Cyg_Scheduler::lock();
sleep();
set_timer( Cyg_Clock::real_time_clock->current_value()+delay, DELAY );
Cyg_Scheduler::unlock();
<---- more ---->
}
-----Original Message-----
From: Wang, Alvin (¤ý©vÙy TAO)
Sent: Thursday, September 18, 2003 5:43 PM
To: 'ecos-discuss@sources.redhat.com'
Subject: cyg_thread_delay problem?
Hi to all,
I use cyg_thread_delay function but it doesn't work. It returns immediately.
I trace the function and find that when execute Cyg_Scheduler::unlock()
it can't swith to another thread.
void
Cyg_Thread::delay( cyg_tick_count delay)
{
CYG_REPORT_FUNCTION();
#ifdef CYGFUN_KERNEL_THREADS_TIMER
CYG_INSTRUMENT_THREAD(DELAY,this,delay);
// Prevent preemption
Cyg_Scheduler::lock();
sleep();
set_timer( Cyg_Clock::real_time_clock->current_value()+delay, DELAY );
// Unlock the scheduler and maybe switch threads
Cyg_Scheduler::unlock();
// Clear the timeout. It is irrelevant whether the alarm has
// actually gone off or not.
clear_timer();
// and deal with anything else we must do when we return
switch( wake_reason ) {
case DESTRUCT:
case EXIT:
exit();
break;
default:
break;
}
#endif
CYG_REPORT_RETURN();
}
The cyg_current_time() function works correcttly, so the
real time clock also works. So could you tell me what is wrong?
And what should I do?
Thank you very much.
Best Regards,
Alvin Wang ¤ý©vÙy
Software Design Dept. Inventec (TAO)
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss