This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Unable to put cyg_thread_delay
- From: "Romil Shah" <rshah at slscorp dot com>
- To: "Ecos-Discuss" <ecos-discuss at sources dot redhat dot com>
- Cc: <gary at mlbassoc dot com>, <radhaamanji at yahoo dot co dot uk>, <fredrik at wespot dot com>, <Thomas dot Koeller at baslerweb dot com>
- Date: Mon, 5 Jul 2004 12:41:45 +0530
- Subject: [ECOS] Unable to put cyg_thread_delay
Sir,
I have created an application with 3 threads ,and attached a delay for
each of them the application is as follows,
static cyg_interrupt int1;
static cyg_handle_t int1_handle;
static cyg_sem_t data_ready;
int thread_a_stack[ THREAD_A_STACK_SIZE ];
int thread_b_stack[ THREAD_B_STACK_SIZE ];
int thread_c_stack[ THREAD_C_STACK_SIZE ];
cyg_handle_t thread_a_handle;
cyg_handle_t thread_b_handle;
cyg_handle_t thread_c_handle;
cyg_thread thread_a_obj;
cyg_thread thread_b_obj;
cyg_thread thread_c_obj;
void thread_a(cyg_addrword_t index)
{
int A_FLAG = 0;
while(1)
{
delayfun(20);
diag_printf("\n *THREAD_A_EXECUTES*");
diag_printf("\n ");
disp7seg(A_FLAG++);
cyg_semaphore_post(&sem_get_data);
cyg_thread_delay(10); /* Program hang up*/
}
}
void thread_b(cyg_addrword_t index)
{
int B_FLAG = 0x00;
while(1)
{
cyg_semaphore_wait(&sem_get_data);
diag_printf("\n *THREAD_B_EXECUTES*");
if(B_FLAG==0x00)
{
*led_pio = 0xff;
B_FLAG = 0xff;
}
else
{
*led_pio = 0x00;
B_FLAG =0x00;
}
cyg_thread_delay(10);
}
}
void thread_c(cyg_addrword_t index)
{
while(1)
{
cyg_semaphore_wait(&sem_get_data);
delayfun(10);
diag_printf("\n *THREAD_C_EXECUTES*");
}
}
void cyg_user_start(void)
{
cyg_semaphore_init(&data_ready,0);
int ipenable_status=0;
int i=0;
cyg_semaphore_init(&sem_get_data,0);
cyg_thread_create(
24,
thread_a,
0,
"Thread A",
&thread_a_stack,
THREAD_A_STACK_SIZE,
&thread_a_handle,
&thread_a_obj);
cyg_thread_create(
22,
thread_b,
0,
"Thread B",
&thread_b_stack,
THREAD_B_STACK_SIZE,
&thread_b_handle,
&thread_b_obj);
cyg_thread_create(
23,
thread_c,
0,
"Thread C",
&thread_c_stack,
THREAD_C_STACK_SIZE,
&thread_c_handle,
&thread_c_obj);
cyg_thread_resume(thread_a_handle);
cyg_thread_resume(thread_b_handle);
cyg_thread_resume(thread_c_handle);
}
Program get hang up if delay is attached to the thread_a ,but if it is
commented and delay is attached to any other thread then program executes
perfectly.
SO what is the reason for this weired behaviour of cyg_thread_delay for
thread_a.
Frm,
Romil Shah.
_________________________________________________________________
http://www.slscorp.com
_________________________________________________________________
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss