* Re: [ECOS] POSIX threads in ecos
@ 2001-08-13 22:27 Rajeev
2001-08-14 7:23 ` Jonathan Larmour
2001-08-15 1:51 ` Boris V. Guzhov
0 siblings, 2 replies; 6+ messages in thread
From: Rajeev @ 2001-08-13 22:27 UTC (permalink / raw)
To: jlarmour; +Cc: ecos-discuss
[-- Attachment #1: Type: text/plain, Size: 1462 bytes --]
hi ,
this is the program i'm trying to debug, see if you could help?
thanks
rajeev
----- Original Message -----
From: "Jonathan Larmour" <jlarmour@redhat.com>
To: "Rajeev" <rajeev@inablers.net>
Cc: <ecos-discuss@sources.redhat.com>
Sent: Tuesday, August 14, 2001 2:45 iNabler
Subject: Re: [ECOS] POSIX threads in ecos
> Rajeev wrote:
> >
> > hi,
> > i'm trying out the posix threads in ecos. i've three threads
running a
> > simple program.
> > when i dont use the sleep call the threads run happily though not
to
> > the priorities i've set .
> > but when i use the sleep call the output i get is
> > thread1:hello world
> > thread2:hello world
> > thread3:hello world
> > thread1:hello world
> > thread2:hello world
> > thread3:hello world
> > >>>>and then the system does nothing.
> > i'm using an ARM7 based board and i have configured one of
its
timers
> > for the scheduler to use and i'm using a basic tick of 0.5 secs
> > what might be the problem??
>
> What's the program? I should warn you that these multi-threading
problems
> are non-trivial to track down, and therefore aren't the type of thing
I
> would find for you (not a paying customer y'see). If I don't see
anything
> glaringly obvious in the program, you'll just have to debug it I'm
afraid.
>
> Jifl
> --
> Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223)
271062
> Maybe this world is another planet's Hell -Aldous Huxley ||
Opinions==mine
[-- Attachment #2: posix.c --]
[-- Type: text/x-c, Size: 1907 bytes --]
#include <cyg/posix/pthread.h>
#include <signal.h>
#include <cyg/posix/types.h>
#include <cyg/hal/debug.h>
#define NUM_THREADS 3
pthread_mutex_t clib;
char thread_stacks[3][PTHREAD_STACK_MIN * 2];
void *PrintHello(void *threadid)
{
int i;
for(;;){
// pthread_mutex_lock(&clib);
disp("Hello World!"); //i still dont have the printfs on my platform
disp_tag((int)threadid); //just my own debug statements
// pthread_mutex_unlock(&clib);
i = sleep(1);
if(i) {
disp("return value from sleep()");
disp_tag(i);
}
}
}
int main()
{
pthread_t threads[NUM_THREADS];
int rc, t;
pthread_attr_t attr[NUM_THREADS];
struct sched_param sched[NUM_THREADS];
sched[0].sched_priority = 10;
sched[1].sched_priority = 20;
sched[2].sched_priority = 30;
pthread_mutex_init(&clib, NULL);
for(t=0;t < NUM_THREADS;t++){
rc = pthread_attr_init(&attr[t]);
if(rc){
disp("ERROR: return code from pthread_attr_init");
disp_tag(rc);
}
}
for(t=0;t < NUM_THREADS;t++){
rc = pthread_attr_setstackaddr( &attr, (void *)&thread_stacks[t][sizeof(thread_stacks[t])] );
if(rc){
disp("ERROR; return code from pthread_attr_setstackaddr() ");
disp_tag(rc);
}
rc = pthread_attr_setstacksize( &attr, sizeof(thread_stacks[t]) );
if(rc){
disp("ERROR; return code from pthread_attr_setstacksize() ");
disp_tag(rc);
}
rc = pthread_attr_setschedpolicy(&attr[t], SCHED_RR);
if(rc){
disp("ERROR; return code from pthread_attr_schedpolicy() ");
disp_tag(rc);
}
rc = pthread_attr_setschedparam(&attr[t], &sched[t]);
if(rc){
disp("ERROR; return code from pthread_attr_schedparam() ");
disp_tag(rc);
}
rc = pthread_create(&threads[t], &attr[t], PrintHello, (void *)t);
if (rc){
disp("ERROR; return code from pthread_create() ");
disp_tag(rc);
}
}
rc = pause();
if(rc != -1){
disp("ERROR:from pause()");
}
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ECOS] POSIX threads in ecos
2001-08-13 22:27 [ECOS] POSIX threads in ecos Rajeev
@ 2001-08-14 7:23 ` Jonathan Larmour
2001-08-15 1:51 ` Boris V. Guzhov
1 sibling, 0 replies; 6+ messages in thread
From: Jonathan Larmour @ 2001-08-14 7:23 UTC (permalink / raw)
To: Rajeev; +Cc: ecos-discuss
Rajeev wrote:
>
> hi ,
> this is the program i'm trying to debug, see if you could help?
Looks fine. I quickly ran it on the Linux synthetic target and it works
fine. You'll have to debug it more I'm afraid.
Jifl
--
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ECOS] POSIX threads in ecos
2001-08-13 22:27 [ECOS] POSIX threads in ecos Rajeev
2001-08-14 7:23 ` Jonathan Larmour
@ 2001-08-15 1:51 ` Boris V. Guzhov
1 sibling, 0 replies; 6+ messages in thread
From: Boris V. Guzhov @ 2001-08-15 1:51 UTC (permalink / raw)
To: Rajeev; +Cc: ecos-discuss
Hi,
Try to increase the size of the threads stacks.
I think that size =PTHREAD_STACK_MIN * 2 is very small.
--
Boris Guzhov,
St.Petersburg, Russia
----- Original Message -----
From: "Rajeev" <rajeev@inablers.net>
To: <jlarmour@redhat.com>
Cc: <ecos-discuss@sources.redhat.com>
Sent: 14 August, 2001 09:51
Subject: Re: [ECOS] POSIX threads in ecos
> hi ,
> this is the program i'm trying to debug, see if you could help?
> thanks
> rajeev
> ----- Original Message -----
> From: "Jonathan Larmour" <jlarmour@redhat.com>
> To: "Rajeev" <rajeev@inablers.net>
> Cc: <ecos-discuss@sources.redhat.com>
> Sent: Tuesday, August 14, 2001 2:45 iNabler
> Subject: Re: [ECOS] POSIX threads in ecos
>
>
> > Rajeev wrote:
> > >
> > > hi,
> > > i'm trying out the posix threads in ecos. i've three threads
> running a
> > > simple program.
> > > when i dont use the sleep call the threads run happily though not
> to
> > > the priorities i've set .
> > > but when i use the sleep call the output i get is
> > > thread1:hello world
> > > thread2:hello world
> > > thread3:hello world
> > > thread1:hello world
> > > thread2:hello world
> > > thread3:hello world
> > > >>>>and then the system does nothing.
> > > i'm using an ARM7 based board and i have configured one of
> its
> timers
> > > for the scheduler to use and i'm using a basic tick of 0.5 secs
> > > what might be the problem??
> >
> > What's the program? I should warn you that these multi-threading
> problems
> > are non-trivial to track down, and therefore aren't the type of thing
> I
> > would find for you (not a paying customer y'see). If I don't see
> anything
> > glaringly obvious in the program, you'll just have to debug it I'm
> afraid.
> >
> > Jifl
> > --
> > Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223)
> 271062
> > Maybe this world is another planet's Hell -Aldous Huxley ||
> Opinions==mine
>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [ECOS] POSIX threads in ecos
@ 2001-08-13 7:48 Rajeev
2001-08-13 14:16 ` Jonathan Larmour
0 siblings, 1 reply; 6+ messages in thread
From: Rajeev @ 2001-08-13 7:48 UTC (permalink / raw)
To: ecos-discuss
hi,
i'm trying out the posix threads in ecos. i've three threads running a
simple program.
when i dont use the sleep call the threads run happily though not to
the priorities i've set .
but when i use the sleep call the output i get is
thread1:hello world
thread2:hello world
thread3:hello world
thread1:hello world
thread2:hello world
thread3:hello world
>>>>and then the system does nothing.
i'm using an ARM7 based board and i have configured one of its timers
for the scheduler to use and i'm using a basic tick of 0.5 secs
what might be the problem??
thanks for all help
rajeev
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ECOS] POSIX threads in ecos
2001-08-13 7:48 Rajeev
@ 2001-08-13 14:16 ` Jonathan Larmour
2001-08-13 22:29 ` Rajeev S
0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Larmour @ 2001-08-13 14:16 UTC (permalink / raw)
To: Rajeev; +Cc: ecos-discuss
Rajeev wrote:
>
> hi,
> i'm trying out the posix threads in ecos. i've three threads running a
> simple program.
> when i dont use the sleep call the threads run happily though not to
> the priorities i've set .
> but when i use the sleep call the output i get is
> thread1:hello world
> thread2:hello world
> thread3:hello world
> thread1:hello world
> thread2:hello world
> thread3:hello world
> >>>>and then the system does nothing.
> i'm using an ARM7 based board and i have configured one of its timers
> for the scheduler to use and i'm using a basic tick of 0.5 secs
> what might be the problem??
What's the program? I should warn you that these multi-threading problems
are non-trivial to track down, and therefore aren't the type of thing I
would find for you (not a paying customer y'see). If I don't see anything
glaringly obvious in the program, you'll just have to debug it I'm afraid.
Jifl
--
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ECOS] POSIX threads in ecos
2001-08-13 14:16 ` Jonathan Larmour
@ 2001-08-13 22:29 ` Rajeev S
0 siblings, 0 replies; 6+ messages in thread
From: Rajeev S @ 2001-08-13 22:29 UTC (permalink / raw)
To: Rajeev S; +Cc: ecos-discuss
[-- Attachment #1: Type: text/plain, Size: 1453 bytes --]
hi ,
this is the program i'm trying to debug, see if you could help?
thanks
rajeev
----- Original Message -----
From: "Jonathan Larmour" <jlarmour@redhat.com>
To: "Rajeev" <rajeev@inablers.net>
Cc: <ecos-discuss@sources.redhat.com>
Sent: Tuesday, August 14, 2001 2:45 iNabler
Subject: Re: [ECOS] POSIX threads in ecos
> Rajeev wrote:
> >
> > hi,
> > i'm trying out the posix threads in ecos. i've three threads running a
> > simple program.
> > when i dont use the sleep call the threads run happily though not to
> > the priorities i've set .
> > but when i use the sleep call the output i get is
> > thread1:hello world
> > thread2:hello world
> > thread3:hello world
> > thread1:hello world
> > thread2:hello world
> > thread3:hello world
> > >>>>and then the system does nothing.
> > i'm using an ARM7 based board and i have configured one of its
timers
> > for the scheduler to use and i'm using a basic tick of 0.5 secs
> > what might be the problem??
>
> What's the program? I should warn you that these multi-threading problems
> are non-trivial to track down, and therefore aren't the type of thing I
> would find for you (not a paying customer y'see). If I don't see anything
> glaringly obvious in the program, you'll just have to debug it I'm afraid.
>
> Jifl
> --
> Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
> Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine
[-- Attachment #2: posix.c --]
[-- Type: text/x-c, Size: 1906 bytes --]
#include <cyg/posix/pthread.h>
#include <signal.h>
#include <cyg/posix/types.h>
#include <cyg/hal/debug.h>
#define NUM_THREADS 3
pthread_mutex_t clib;
char thread_stacks[3][PTHREAD_STACK_MIN * 2];
void *PrintHello(void *threadid)
{
int i;
for(;;){
// pthread_mutex_lock(&clib);
disp("Hello World!"); //i still dont have the printfs on my platform
disp_tag((int)threadid); //just my own debug statements
// pthread_mutex_unlock(&clib);
i = sleep(1);
if(i) {
disp("return value from sleep()");
disp_tag(i);
}
}
}
int main()
{
pthread_t threads[NUM_THREADS];
int rc, t;
pthread_attr_t attr[NUM_THREADS];
struct sched_param sched[NUM_THREADS];
sched[0].sched_priority = 10;
sched[1].sched_priority = 20;
sched[2].sched_priority = 30;
pthread_mutex_init(&clib, NULL);
for(t=0;t < NUM_THREADS;t++){
rc = pthread_attr_init(&attr[t]);
if(rc){
disp("ERROR: return code from pthread_attr_init");
disp_tag(rc);
}
}
for(t=0;t < NUM_THREADS;t++){
rc = pthread_attr_setstackaddr( &attr, (void *)&thread_stacks[t][sizeof(thread_stacks[t])] );
if(rc){
disp("ERROR; return code from pthread_attr_setstackaddr() ");
disp_tag(rc);
}
rc = pthread_attr_setstacksize( &attr, sizeof(thread_stacks[t]) );
if(rc){
disp("ERROR; return code from pthread_attr_setstacksize() ");
disp_tag(rc);
}
rc = pthread_attr_setschedpolicy(&attr[t], SCHED_RR);
if(rc){
disp("ERROR; return code from pthread_attr_schedpolicy() ");
disp_tag(rc);
}
rc = pthread_attr_setschedparam(&attr[t], &sched[t]);
if(rc){
disp("ERROR; return code from pthread_attr_schedparam() ");
disp_tag(rc);
}
rc = pthread_create(&threads[t], &attr[t], PrintHello, (void *)t);
if (rc){
disp("ERROR; return code from pthread_create() ");
disp_tag(rc);
}
}
rc = pause();
if(rc != -1){
disp("ERROR:from pause()");
}
}
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2001-08-15 1:51 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-13 22:27 [ECOS] POSIX threads in ecos Rajeev
2001-08-14 7:23 ` Jonathan Larmour
2001-08-15 1:51 ` Boris V. Guzhov
-- strict thread matches above, loose matches on Subject: below --
2001-08-13 7:48 Rajeev
2001-08-13 14:16 ` Jonathan Larmour
2001-08-13 22:29 ` Rajeev S
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).