* [ECOS] therad delay problem
@ 2003-11-25 5:36 Aravind B
2003-11-25 8:30 ` Andrew Lunn
0 siblings, 1 reply; 3+ messages in thread
From: Aravind B @ 2003-11-25 5:36 UTC (permalink / raw)
To: ecos-discuss
hi,
i have written a program which contains 3 thread as shown.
cyg_user_start(void)
{
printf("entering two threads cyg_user_start() function\n");
cyg_mutex_init(&cliblock);
cyg_thread_create(3,simple_program,(cyg_addrword_t)2,
"simple_program_Thread ",(void*) stack[2],4096,
&simple_program_Thread,&thread_s[2]);
cyg_thread_create(4,simple_program1,(cyg_addrword_t)3,
"simple_program1_Thread",(void*) stack[3],4096,
&simple_program1_Thread,&thread_s[3]);
cyg_thread_create(5,simple_program2,(cyg_addrword_t)4,
"simple_program2_Thread",(void*) stack[4],4096,
&simple_program2_Thread,&thread_s[4]);
cyg_thread_resume(simple_program_Thread);
cyg_thread_resume(simple_program1_Thread);
cyg_thread_resume(simple_program2_Thread);
}
cyg_alarm_t alarm_Tbcn_func;
void simple_program(cyg_addrword_t data )
{
int message=(int) data;
unsigned int i;
printf("i am thread %d before delay\n",message);
curr_time=cyg_real_time_clock();
cyg_clock_to_counter(curr_time,&handle_counterTbcn);
cyg_alarm_create(handle_counterTbcn, alarm_Tbcn_func,5500,
&handle_alarmTbcn, &alarm_Tbcn);
cyg_alarm_initialize(handle_alarmTbcn,cyg_current_time()+200,0);
cyg_thread_delay(3);
while(1)
{
if(var==1)
{
printf(" hello");
break;
}
}
}
void simple_program1(cyg_addrword_t data )
{
int message=(int) data;
printf("i am thread %d\n",message);
}
void simple_program2(cyg_addrword_t data )
{
int message=(int) data;
printf("i am thread %d\n",message);
while(1)
{
}
}
void alarm_Tbcn_func( cyg_handle_t alarmTbcn,cyg_addrword_t data)
{
var=1;
printf(" i am in alarm function\n");
}
there is cyg_thread _delay(3) in t1.the control goes to t2 and then
t3.In t3 i have infinite while loop.The control is not going to t1.Is
there any way so that i can signal to t1 that thread delay is over and
it can continue its flow.If so then how it is?
thank u in advance
#############################
Aravind B
Trainee Engineer.
CSIL.
_______________________________________________
This email with any attachments is for the exclusive use of the intended
recipient/s & may contain confidential & legally privileged information.
If you are not the intended recipient pls notify the sender immediately
& delete the email from your system. Any unauthorised use, disclosure,
printing, dissemination, forwarding or copying of this mail is strictly
prohibited and unlawful.
Visit us at : http://www.cranessoftware.com
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [ECOS] therad delay problem
2003-11-25 5:36 [ECOS] therad delay problem Aravind B
@ 2003-11-25 8:30 ` Andrew Lunn
2003-11-25 12:58 ` Gary Thomas
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Lunn @ 2003-11-25 8:30 UTC (permalink / raw)
To: Aravind B; +Cc: ecos-discuss
On Tue, Nov 25, 2003 at 10:59:06AM +0530, Aravind B wrote:
> hi,
> i have written a program which contains 3 thread as shown.
>
> cyg_user_start(void)
> {
>
> printf("entering two threads cyg_user_start() function\n");
>
> cyg_mutex_init(&cliblock);
> cyg_thread_create(3,simple_program,(cyg_addrword_t)2,
> "simple_program_Thread ",(void*) stack[2],4096,
> &simple_program_Thread,&thread_s[2]);
> cyg_thread_create(4,simple_program1,(cyg_addrword_t)3,
> "simple_program1_Thread",(void*) stack[3],4096,
> &simple_program1_Thread,&thread_s[3]);
> cyg_thread_create(5,simple_program2,(cyg_addrword_t)4,
> "simple_program2_Thread",(void*) stack[4],4096,
> &simple_program2_Thread,&thread_s[4]);
>
> cyg_thread_resume(simple_program_Thread);
> cyg_thread_resume(simple_program1_Thread);
> cyg_thread_resume(simple_program2_Thread);
> }
> cyg_alarm_t alarm_Tbcn_func;
>
> void simple_program(cyg_addrword_t data )
> {
> int message=(int) data;
> unsigned int i;
> printf("i am thread %d before delay\n",message);
>
> curr_time=cyg_real_time_clock();
> cyg_clock_to_counter(curr_time,&handle_counterTbcn);
> cyg_alarm_create(handle_counterTbcn, alarm_Tbcn_func,5500,
> &handle_alarmTbcn, &alarm_Tbcn);
> cyg_alarm_initialize(handle_alarmTbcn,cyg_current_time()+200,0);
>
> cyg_thread_delay(3);
> while(1)
> {
> if(var==1)
> {
> printf(" hello");
> break;
> }
> }
> }
>
> void simple_program1(cyg_addrword_t data )
> {
> int message=(int) data;
> printf("i am thread %d\n",message);
> }
>
> void simple_program2(cyg_addrword_t data )
> {
> int message=(int) data;
> printf("i am thread %d\n",message);
> while(1)
> {
> }
> }
> void alarm_Tbcn_func( cyg_handle_t alarmTbcn,cyg_addrword_t data)
> {
> var=1;
> printf(" i am in alarm function\n");
> }
>
>
> there is cyg_thread _delay(3) in t1.the control goes to t2 and then
> t3.In t3 i have infinite while loop.The control is not going to t1.Is
> there any way so that i can signal to t1 that thread delay is over and
> it can continue its flow.If so then how it is?
Does the alarm hander get called?
it var a volatile?
Andrew
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [ECOS] therad delay problem
2003-11-25 8:30 ` Andrew Lunn
@ 2003-11-25 12:58 ` Gary Thomas
0 siblings, 0 replies; 3+ messages in thread
From: Gary Thomas @ 2003-11-25 12:58 UTC (permalink / raw)
To: Andrew Lunn; +Cc: Aravind B, ecos-discuss
On Tue, 2003-11-25 at 01:30, Andrew Lunn wrote:
> On Tue, Nov 25, 2003 at 10:59:06AM +0530, Aravind B wrote:
> > hi,
> > i have written a program which contains 3 thread as shown.
> >
> > cyg_user_start(void)
> > {
> >
> > printf("entering two threads cyg_user_start() function\n");
> >
> > cyg_mutex_init(&cliblock);
> > cyg_thread_create(3,simple_program,(cyg_addrword_t)2,
> > "simple_program_Thread ",(void*) stack[2],4096,
> > &simple_program_Thread,&thread_s[2]);
> > cyg_thread_create(4,simple_program1,(cyg_addrword_t)3,
> > "simple_program1_Thread",(void*) stack[3],4096,
> > &simple_program1_Thread,&thread_s[3]);
> > cyg_thread_create(5,simple_program2,(cyg_addrword_t)4,
> > "simple_program2_Thread",(void*) stack[4],4096,
> > &simple_program2_Thread,&thread_s[4]);
> >
> > cyg_thread_resume(simple_program_Thread);
> > cyg_thread_resume(simple_program1_Thread);
> > cyg_thread_resume(simple_program2_Thread);
> > }
> > cyg_alarm_t alarm_Tbcn_func;
> >
> > void simple_program(cyg_addrword_t data )
> > {
> > int message=(int) data;
> > unsigned int i;
> > printf("i am thread %d before delay\n",message);
> >
> > curr_time=cyg_real_time_clock();
> > cyg_clock_to_counter(curr_time,&handle_counterTbcn);
> > cyg_alarm_create(handle_counterTbcn, alarm_Tbcn_func,5500,
> > &handle_alarmTbcn, &alarm_Tbcn);
> > cyg_alarm_initialize(handle_alarmTbcn,cyg_current_time()+200,0);
> >
> > cyg_thread_delay(3);
> > while(1)
> > {
> > if(var==1)
> > {
> > printf(" hello");
> > break;
> > }
> > }
> > }
> >
> > void simple_program1(cyg_addrword_t data )
> > {
> > int message=(int) data;
> > printf("i am thread %d\n",message);
> > }
> >
> > void simple_program2(cyg_addrword_t data )
> > {
> > int message=(int) data;
> > printf("i am thread %d\n",message);
> > while(1)
> > {
> > }
> > }
> > void alarm_Tbcn_func( cyg_handle_t alarmTbcn,cyg_addrword_t data)
> > {
> > var=1;
> > printf(" i am in alarm function\n");
> > }
> >
> >
> > there is cyg_thread _delay(3) in t1.the control goes to t2 and then
> > t3.In t3 i have infinite while loop.The control is not going to t1.Is
> > there any way so that i can signal to t1 that thread delay is over and
> > it can continue its flow.If so then how it is?
>
> Does the alarm hander get called?
>
> it var a volatile?
Does your program include <cyg/kernel/kapi.h>
See: http://ecos.sourceware.org/fom-serv/ecos/cache/94.html
--
Gary Thomas <gary@mlbassoc.com>
MLB Associates
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-11-25 12:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-25 5:36 [ECOS] therad delay problem Aravind B
2003-11-25 8:30 ` Andrew Lunn
2003-11-25 12:58 ` Gary Thomas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).