This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: cyg_alarm_initilize
On Tuesday 04 April 2006 15:40, you wrote:
Hi Andrew,
Thanks for ur reply.But I have simple code on alarm, I will give it below.
#define PRIORITY 10
#define WORK_PRIORITY 11
#define STACKSIZE 1024
unsigned char stack[ STACKSIZE ];
unsigned char work_stacks[STACKSIZE];
cyg_handle_t handle,work_handles;
cyg_thread thread,work_threads;
cyg_flag_t flag;
cyg_flag_value_t value,pattern;
cyg_flag_mode_t mode;
cyg_handle_t counter_hdl;
cyg_handle_t sys_clk;
cyg_handle_t alarm_hdl;
cyg_alarm_t alarm_handler;
cyg_alarm alarm_obj;
cyg_mutex_t cliblock;
void alarm_handler( cyg_handle_t alarm_handle, cyg_addrword_t data )
{
value = 1;
cyg_flag_setbits(&flag,pattern);
}
void work(cyg_addrword_t data)
{
while(1)
{
cyg_mutex_lock(&cliblock);
printf("In worker thread\n");
cyg_mutex_unlock(&cliblock);
}
}
void counter_thread(cyg_addrword_t data)
{
while(1)
{
value = 0xfffffffe;
pattern = 1;
mode=CYG_FLAG_WAITMODE_OR ;
cyg_flag_maskbits(&flag,value);
cyg_alarm_initialize( alarm_hdl, 10 + cyg_current_time() , 0 );
value=cyg_flag_wait(&flag,pattern,mode);
}
}
void cyg_user_start()
{
sys_clk = cyg_real_time_clock();
cyg_clock_to_counter( sys_clk, &counter_hdl );
cyg_alarm_create( counter_hdl, alarm_handler, (cyg_addrword_t)&index1,
&alarm_hdl, &alarm_obj );
cyg_mutex_init(&cliblock);
cyg_thread_create(10, &counter_thread, 0 ,"counter_thread", stack, STACKSIZE,
&handle, &thread);
cyg_thread_resume(handle);
cyg_thread_create(11, &work , 0, "work",work_stacks, STACKSIZE,
&(work_handles),&(work_threads));
cyg_thread_resume(work_handles);
}
when I run this code the printf in worker's thread got struck at one
ponit...Why???? Plz reply.and how can I make the code to run continiously.???
Thanks
Vasanth
> On Mon, Apr 03, 2006 at 07:40:48PM +0530, vasantha.rajan wrote:
> > I have some problem in cyg_alarn_initialize() API.
> >
> > Our code contains nearly 20 threads sheduled to run. In one particular
> > thread we have cyg_alarm_initilize() api as give below,
> > cyg_alarm_initialize(handle_alarmTbcn,cyg_current_time() + 10 , 0 );(ie
> > my alarm triggers fo every 100ms)
> >
> > In my CDL i have my CYGNUM_HAL_RTC_NUMERATOR value as 1000000000 and
> > CYGNUM_HAL_RTC_DENOMINATOR value as 100.
> >
> > My problem is the code strucks at some point, I think there is some
> > problem with alarm api and kernel timer.
>
> The timer code is very mature. The problem is more likely to be in
> your code. Try enabling CYGPKG_INFRA_DEBUG.
>
> Andrew
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss