* Problems with pthread on ARM/PXA270
2009-09-16 7:26 Problems with pthread on ARM/PXA270 Juergen Schindele
@ 2009-09-16 14:14 ` Eric Miao
2009-09-16 15:01 ` Juergen Schindele
2009-09-16 14:40 ` Daniel Jacobowitz
` (3 subsequent siblings)
4 siblings, 1 reply; 16+ messages in thread
From: Eric Miao @ 2009-09-16 14:14 UTC (permalink / raw)
To: linux-arm-kernel
Don't remember we had such problems before. What kind of system
and libraries are you using?
On Wed, Sep 16, 2009 at 3:26 PM, Juergen Schindele <schindele@nentec.de> wrote:
> Hello all,
> we tried to implement a thread based software on our PXA270 based platform but
> we had trouble with pthreads. So i modyfied a tiny progam to test. This little progam creates
> 10 threads and each thread does print something (an index an a pointer to itself).
>
> On my PC with Suse 11.0 Linux (kernel 2.6.27) this works fine as supposed to.
> Each thread has his turn and print his own values.
>
> But on our pxa270 platform the thread switch does not (or really rarely) happen
> and only one thread is printing always the same values. So i suppose thread
> switching is not working!
>
> Any hints or experiences are welcome !!!
>
> we use codesourcery compiler
> arm-none-linux-gnueabi-gcc (CodeSourcery Sourcery G++ Lite 2007q1-10) 4.2.0 20070413 (prerelease)
> Copyright (C) 2007 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. ?There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> and here the C-code compiled with ?"arm-none-linux-gnueabi-gcc -o test test.c -lpthread"
>
> #include <errno.h>
> #include <error.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <pthread.h>
> #include <time.h>
>
> #define NUM_THREADS 10
> #define NUM_ITERS ? 50
> #define TIMEOUT_NS ?100000000L
>
> static void *thread (void *);
> static int argument[NUM_THREADS];
> static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
> static pthread_attr_t defaultattr;
>
> static void * print_thread (void *arg)
> {
> ? ?int i;
> ? ?int number = *((int*)arg);
>
> ? ?for (;;) {
> ? ? ? ?pthread_t self = pthread_self ();
> ? ? ? ?printf ("Thread %d is [%d]\n", number, self);
> ? ?}
> }
>
> int main (void)
> {
> ? ?pthread_t th;
> ? ?int i, retvalue;
>
> ? ?struct sched_param param;
> ? ?pthread_attr_init(&defaultattr);
>
> ? ?pthread_attr_setschedpolicy(&defaultattr, SCHED_RR);
>
> ? ?param.sched_priority = 10;
> ? ?if ((retvalue = pthread_attr_setschedparam(&defaultattr, ¶m))!=0) {
> ? ? ? ?printf ("ERROR\n");
> ? ? ? ?exit (0);
> ? ?}
>
> ? ?for (i = 0; i < NUM_THREADS; i++)
> ? ?{
> ? ? ? ?argument[i] = i;
> ? ? ? ?if (pthread_create (&th, &defaultattr, print_thread, &argument[i]) != 0)
> ? ? ? ? ? ?error (EXIT_FAILURE, 0, "cannot create thread");
> ? ? ? ?printf ("Thread [%d]\n", i);
> ? ?}
>
> ? ?while (1) {
> ? ? ? ?;
> ? ?}
>
> ? ?/* notreached */
> ? ?return 0;
> }
>
> --------------------------------------------------------------
> J?rgen Schindele
> Software-Entwicklung
>
> NENTEC Netzwerktechnologie GmbH
> Greschbachstr. 12
> 76229 Karlsruhe
> Deutschland
> Telefon: +49 721 94249-51
> Telefax: +49 721 94249-10
> E-Mail: ?schindele at nentec.de
> WEB: ? ? www.nentec.de
>
> Gesch?ftsf?hrung: Klaus Becker, Roland Knapp
> Sitz der Gesellschaft: Karlsruhe
> Handelsregister: Amtsgericht Mannheim HRB 107658
> --------------------------------------------------------------
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
^ permalink raw reply [flat|nested] 16+ messages in thread* Problems with pthread on ARM/PXA270
2009-09-16 14:14 ` Eric Miao
@ 2009-09-16 15:01 ` Juergen Schindele
2009-09-16 15:06 ` Eric Miao
0 siblings, 1 reply; 16+ messages in thread
From: Juergen Schindele @ 2009-09-16 15:01 UTC (permalink / raw)
To: linux-arm-kernel
Am Mittwoch, 16. September 2009 schrieb Eric Miao:
> Don't remember we had such problems before. What kind of system
> and libraries are you using?
thanks for your reply.
System is custom PXA270 platform.
with codesourcery compiler (see below)
and glibc 2.5 with pthread.
I dont know what more information to give ?
>
>
> On Wed, Sep 16, 2009 at 3:26 PM, Juergen Schindele <schindele@nentec.de> wrote:
> > Hello all,
> > we tried to implement a thread based software on our PXA270 based platform but
> > we had trouble with pthreads. So i modyfied a tiny progam to test. This little progam creates
> > 10 threads and each thread does print something (an index an a pointer to itself).
> >
> > On my PC with Suse 11.0 Linux (kernel 2.6.27) this works fine as supposed to.
> > Each thread has his turn and print his own values.
> >
> > But on our pxa270 platform the thread switch does not (or really rarely) happen
> > and only one thread is printing always the same values. So i suppose thread
> > switching is not working!
> >
> > Any hints or experiences are welcome !!!
> >
> > we use codesourcery compiler
> > arm-none-linux-gnueabi-gcc (CodeSourcery Sourcery G++ Lite 2007q1-10) 4.2.0 20070413 (prerelease)
> > Copyright (C) 2007 Free Software Foundation, Inc.
> > This is free software; see the source for copying conditions. ?There is NO
> > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> >
> > and here the C-code compiled with ?"arm-none-linux-gnueabi-gcc -o test test.c -lpthread"
> >
> > #include <errno.h>
> > #include <error.h>
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <pthread.h>
> > #include <time.h>
> >
> > #define NUM_THREADS 10
> > #define NUM_ITERS ? 50
> > #define TIMEOUT_NS ?100000000L
> >
> > static void *thread (void *);
> > static int argument[NUM_THREADS];
> > static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
> > static pthread_attr_t defaultattr;
> >
> > static void * print_thread (void *arg)
> > {
> > ? ?int i;
> > ? ?int number = *((int*)arg);
> >
> > ? ?for (;;) {
> > ? ? ? ?pthread_t self = pthread_self ();
> > ? ? ? ?printf ("Thread %d is [%d]\n", number, self);
> > ? ?}
> > }
> >
> > int main (void)
> > {
> > ? ?pthread_t th;
> > ? ?int i, retvalue;
> >
> > ? ?struct sched_param param;
> > ? ?pthread_attr_init(&defaultattr);
> >
> > ? ?pthread_attr_setschedpolicy(&defaultattr, SCHED_RR);
> >
> > ? ?param.sched_priority = 10;
> > ? ?if ((retvalue = pthread_attr_setschedparam(&defaultattr, ¶m))!=0) {
> > ? ? ? ?printf ("ERROR\n");
> > ? ? ? ?exit (0);
> > ? ?}
> >
> > ? ?for (i = 0; i < NUM_THREADS; i++)
> > ? ?{
> > ? ? ? ?argument[i] = i;
> > ? ? ? ?if (pthread_create (&th, &defaultattr, print_thread, &argument[i]) != 0)
> > ? ? ? ? ? ?error (EXIT_FAILURE, 0, "cannot create thread");
> > ? ? ? ?printf ("Thread [%d]\n", i);
> > ? ?}
> >
> > ? ?while (1) {
> > ? ? ? ?;
> > ? ?}
> >
> > ? ?/* notreached */
> > ? ?return 0;
> > }
> >
> > --------------------------------------------------------------
> > J?rgen Schindele
> > Software-Entwicklung
> >
> > NENTEC Netzwerktechnologie GmbH
> > Greschbachstr. 12
> > 76229 Karlsruhe
> > Deutschland
> > Telefon: +49 721 94249-51
> > Telefax: +49 721 94249-10
> > E-Mail: ?schindele at nentec.de
> > WEB: ? ? www.nentec.de
> >
> > Gesch?ftsf?hrung: Klaus Becker, Roland Knapp
> > Sitz der Gesellschaft: Karlsruhe
> > Handelsregister: Amtsgericht Mannheim HRB 107658
> > --------------------------------------------------------------
> >
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel at lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> >
>
>
--
--------------------------------------------------------------
J?rgen Schindele
Software-Entwicklung
NENTEC Netzwerktechnologie GmbH
Greschbachstr. 12
76229 Karlsruhe
Deutschland
Telefon: +49 721 94249-51
Telefax: +49 721 94249-10
E-Mail: schindele at nentec.de
WEB: www.nentec.de
Gesch?ftsf?hrung: Klaus Becker, Roland Knapp
Sitz der Gesellschaft: Karlsruhe
Handelsregister: Amtsgericht Mannheim HRB 107658
Diese E-Mail enth?lt vertrauliche oder rechtlich gesch?tzte Informationen.
Wenn Sie nicht der vorgesehene Empf?nger sind, informieren Sie bitte sofort
den Absender und l?schen Sie diese E-Mail. Das unbefugte Kopieren dieser E-Mail
oder die unbefugte Weitergabe der enthaltenen Informationen ist nicht gestattet.
The information contained in this message is confidential or protected by law.
If you are not the intended recipient, please contact the sender and delete this
message. Any unauthorised copying of this message or unauthorised distribution of
the information contained herein is prohibited.
--------------------------------------------------------------
^ permalink raw reply [flat|nested] 16+ messages in thread* Problems with pthread on ARM/PXA270
2009-09-16 15:01 ` Juergen Schindele
@ 2009-09-16 15:06 ` Eric Miao
2009-09-17 7:35 ` Juergen Schindele
0 siblings, 1 reply; 16+ messages in thread
From: Eric Miao @ 2009-09-16 15:06 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Sep 16, 2009 at 11:01 PM, Juergen Schindele <schindele@nentec.de> wrote:
> Am Mittwoch, 16. September 2009 schrieb Eric Miao:
>> Don't remember we had such problems before. What kind of system
>> and libraries are you using?
> thanks for your reply.
> System is custom PXA270 platform.
> with codesourcery compiler (see below)
> and glibc 2.5 with pthread.
> I dont know what more information to give ?
Like which kernel version, where do you get the glibc-2.5 and pthread binary,
or you compiled it from scratch, and with which compiler of which version?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Problems with pthread on ARM/PXA270
2009-09-16 15:06 ` Eric Miao
@ 2009-09-17 7:35 ` Juergen Schindele
2009-09-17 12:47 ` Beckwith, Stephen (Stephen)
0 siblings, 1 reply; 16+ messages in thread
From: Juergen Schindele @ 2009-09-17 7:35 UTC (permalink / raw)
To: linux-arm-kernel
Am Mittwoch, 16. September 2009 schrieb Eric Miao:
> On Wed, Sep 16, 2009 at 11:01 PM, Juergen Schindele <schindele@nentec.de> wrote:
> > Am Mittwoch, 16. September 2009 schrieb Eric Miao:
> >> Don't remember we had such problems before. What kind of system
> >> and libraries are you using?
> > thanks for your reply.
> > System is custom PXA270 platform.
> > with codesourcery compiler (see below)
> > and glibc 2.5 with pthread.
> > I dont know what more information to give ?
>
> Like which kernel version, where do you get the glibc-2.5 and pthread binary,
Sorry forgot that completely !
Kernel version tested is 2.6.16 and 2.6.20 (sorry no newer version available yet)
Compiler , GlibC, pthread all come from Codesourcery precompiled in a package
"CodeSourcery Sourcery G++ Lite 2007q1-10" downloadable for free.
Compiler version is as mentioned before :
arm-none-linux-gnueabi-gcc (CodeSourcery Sourcery G++ Lite 2007q1-10) 4.2.0 20070413 (prerelease)
--------------------------------------------------------------
J?rgen Schindele
Software-Entwicklung
NENTEC Netzwerktechnologie GmbH
Greschbachstr. 12
76229 Karlsruhe
Deutschland
Telefon: +49 721 94249-51
Telefax: +49 721 94249-10
E-Mail: schindele at nentec.de
WEB: www.nentec.de
Gesch?ftsf?hrung: Klaus Becker, Roland Knapp
Sitz der Gesellschaft: Karlsruhe
Handelsregister: Amtsgericht Mannheim HRB 107658
--------------------------------------------------------------
^ permalink raw reply [flat|nested] 16+ messages in thread
* Problems with pthread on ARM/PXA270
2009-09-17 7:35 ` Juergen Schindele
@ 2009-09-17 12:47 ` Beckwith, Stephen (Stephen)
2009-09-17 13:06 ` Juergen Schindele
2009-09-21 21:19 ` Beckwith, Stephen (Stephen)
0 siblings, 2 replies; 16+ messages in thread
From: Beckwith, Stephen (Stephen) @ 2009-09-17 12:47 UTC (permalink / raw)
To: linux-arm-kernel
Greetings All,
I will quickly add the following to this thread, as it seems related.
Platform:
Custom ARM9 SoC using Montavista Linux Release 3.1, a 2.4.21 Linux Kernel. Montavista tool chain and libraries.
Problem:
When we try and execute a pthread_create, "when loaded as a .so", the thread will be created, but will not "return" to the main thread for further processing, we basically get "stuck" in this new thread. In the "real" case, this is an ISR thread, would hang on waiting for an interrupt. For testing, I use Sleep and prints to document program flow.
However, IF I use the "exact same code" and build the program as an application, it works just fine dandy. . . The thread gets spawned, prints it's initial hello, then goes into the while (1) sleep/print incrementing value loop. The thread returns to the "Main" and we spawn 2 more threads and they work just fine (based upon interleaving printouts)
NOTE:
For our "normal" development we use an external host processor (PowerPC based) to control the SoC and the ability to create threads from a .so has worked in this setup (using same MVL 3.1 kernel/toolchain) for the past 4+ years on 10's of platforms. So we suspected some issue/problem with the MVL setup
Now, we are migrating to a new ARM11 based SoC and I am in the process of re-testing this functionality.
This new platform will be based upon 2.6.28 kernel release and CodeSourcery G++ Lite 2008q3-72 tools/libraries.
I'm in the process of setting this up on an ARM RealView EB.
Details to follow.
Regards,
Stephen Beckwith
-----Original Message-----
From: linux-arm-kernel-bounces@lists.infradead.org [mailto:linux-arm-kernel-bounces at lists.infradead.org] On Behalf Of Juergen Schindele
Sent: Thursday, September 17, 2009 3:36 AM
To: linux-arm-kernel at lists.infradead.org
Cc: Eric Miao
Subject: Re: Problems with pthread on ARM/PXA270
Am Mittwoch, 16. September 2009 schrieb Eric Miao:
> On Wed, Sep 16, 2009 at 11:01 PM, Juergen Schindele <schindele@nentec.de> wrote:
> > Am Mittwoch, 16. September 2009 schrieb Eric Miao:
> >> Don't remember we had such problems before. What kind of system
> >> and libraries are you using?
> > thanks for your reply.
> > System is custom PXA270 platform.
> > with codesourcery compiler (see below)
> > and glibc 2.5 with pthread.
> > I dont know what more information to give ?
>
> Like which kernel version, where do you get the glibc-2.5 and pthread binary,
Sorry forgot that completely !
Kernel version tested is 2.6.16 and 2.6.20 (sorry no newer version available yet)
Compiler , GlibC, pthread all come from Codesourcery precompiled in a package
"CodeSourcery Sourcery G++ Lite 2007q1-10" downloadable for free.
Compiler version is as mentioned before :
arm-none-linux-gnueabi-gcc (CodeSourcery Sourcery G++ Lite 2007q1-10) 4.2.0 20070413 (prerelease)
--------------------------------------------------------------
J?rgen Schindele
Software-Entwicklung
NENTEC Netzwerktechnologie GmbH
Greschbachstr. 12
76229 Karlsruhe
Deutschland
Telefon: +49 721 94249-51
Telefax: +49 721 94249-10
E-Mail: schindele at nentec.de
WEB: www.nentec.de
Gesch?ftsf?hrung: Klaus Becker, Roland Knapp
Sitz der Gesellschaft: Karlsruhe
Handelsregister: Amtsgericht Mannheim HRB 107658
--------------------------------------------------------------
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 16+ messages in thread
* Problems with pthread on ARM/PXA270
2009-09-17 12:47 ` Beckwith, Stephen (Stephen)
@ 2009-09-17 13:06 ` Juergen Schindele
2009-09-21 21:19 ` Beckwith, Stephen (Stephen)
1 sibling, 0 replies; 16+ messages in thread
From: Juergen Schindele @ 2009-09-17 13:06 UTC (permalink / raw)
To: linux-arm-kernel
Am Donnerstag, 17. September 2009 schrieb Beckwith, Stephen (Stephen):
> Greetings All,
> I will quickly add the following to this thread, as it seems related.
> Platform:
> Custom ARM9 SoC using Montavista Linux Release 3.1, a 2.4.21 Linux Kernel. Montavista tool chain and libraries.
Stephen thanks for your comment.
I tested with Montavista toolchain and 2.6.12 kernel too but without success.
Perhaps this is arm/arch implementation dependant ???
>
> Problem:
> When we try and execute a pthread_create, "when loaded as a .so", the thread will be created, but will not "return" to the main thread for further processing, we basically get "stuck" in this new thread. In the "real" case, this is an ISR thread, would hang on waiting for an interrupt. For testing, I use Sleep and prints to document program flow.
As you see the example i sent in first mail i build a simple application, so it should work.
Can you please test this little prog on your environment/platform ?
> However, IF I use the "exact same code" and build the program as an application, it works just fine dandy. . . The thread gets spawned, prints it's initial hello, then goes into the while (1) sleep/print incrementing value loop. The thread returns to the "Main" and we spawn 2 more threads and they work just fine (based upon interleaving printouts)
This seems to be dependant of memory location or what ?
What parameters do you use for creating your threads ?
>
> NOTE:
> For our "normal" development we use an external host processor (PowerPC based) to control the SoC and the ability to create threads from a .so has worked in this setup (using same MVL 3.1 kernel/toolchain) for the past 4+ years on 10's of platforms. So we suspected some issue/problem with the MVL setup
>
>
> Now, we are migrating to a new ARM11 based SoC and I am in the process of re-testing this functionality.
> This new platform will be based upon 2.6.28 kernel release and CodeSourcery G++ Lite 2008q3-72 tools/libraries.
> I'm in the process of setting this up on an ARM RealView EB.
>
> Details to follow.
>
> Regards,
> Stephen Beckwith
>
>
> -----Original Message-----
> From: linux-arm-kernel-bounces at lists.infradead.org [mailto:linux-arm-kernel-bounces at lists.infradead.org] On Behalf Of Juergen Schindele
> Sent: Thursday, September 17, 2009 3:36 AM
> To: linux-arm-kernel at lists.infradead.org
> Cc: Eric Miao
> Subject: Re: Problems with pthread on ARM/PXA270
>
> Am Mittwoch, 16. September 2009 schrieb Eric Miao:
> > On Wed, Sep 16, 2009 at 11:01 PM, Juergen Schindele <schindele@nentec.de> wrote:
> > > Am Mittwoch, 16. September 2009 schrieb Eric Miao:
> > >> Don't remember we had such problems before. What kind of system
> > >> and libraries are you using?
> > > thanks for your reply.
> > > System is custom PXA270 platform.
> > > with codesourcery compiler (see below)
> > > and glibc 2.5 with pthread.
> > > I dont know what more information to give ?
> >
> > Like which kernel version, where do you get the glibc-2.5 and pthread binary,
> Sorry forgot that completely !
> Kernel version tested is 2.6.16 and 2.6.20 (sorry no newer version available yet)
> Compiler , GlibC, pthread all come from Codesourcery precompiled in a package
> "CodeSourcery Sourcery G++ Lite 2007q1-10" downloadable for free.
> Compiler version is as mentioned before :
> arm-none-linux-gnueabi-gcc (CodeSourcery Sourcery G++ Lite 2007q1-10) 4.2.0 20070413 (prerelease)
>
> --------------------------------------------------------------
> J?rgen Schindele
> Software-Entwicklung
>
> NENTEC Netzwerktechnologie GmbH
> Greschbachstr. 12
> 76229 Karlsruhe
> Deutschland
> Telefon: +49 721 94249-51
> Telefax: +49 721 94249-10
> E-Mail: schindele at nentec.de
> WEB: www.nentec.de
>
> Gesch?ftsf?hrung: Klaus Becker, Roland Knapp
> Sitz der Gesellschaft: Karlsruhe
> Handelsregister: Amtsgericht Mannheim HRB 107658
> --------------------------------------------------------------
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
>
--
--------------------------------------------------------------
J?rgen Schindele
Software-Entwicklung
NENTEC Netzwerktechnologie GmbH
Greschbachstr. 12
76229 Karlsruhe
Deutschland
Telefon: +49 721 94249-51
Telefax: +49 721 94249-10
E-Mail: schindele at nentec.de
WEB: www.nentec.de
Gesch?ftsf?hrung: Klaus Becker, Roland Knapp
Sitz der Gesellschaft: Karlsruhe
Handelsregister: Amtsgericht Mannheim HRB 107658
Diese E-Mail enth?lt vertrauliche oder rechtlich gesch?tzte Informationen.
Wenn Sie nicht der vorgesehene Empf?nger sind, informieren Sie bitte sofort
den Absender und l?schen Sie diese E-Mail. Das unbefugte Kopieren dieser E-Mail
oder die unbefugte Weitergabe der enthaltenen Informationen ist nicht gestattet.
The information contained in this message is confidential or protected by law.
If you are not the intended recipient, please contact the sender and delete this
message. Any unauthorised copying of this message or unauthorised distribution of
the information contained herein is prohibited.
--------------------------------------------------------------
^ permalink raw reply [flat|nested] 16+ messages in thread
* Problems with pthread on ARM/PXA270
2009-09-17 12:47 ` Beckwith, Stephen (Stephen)
2009-09-17 13:06 ` Juergen Schindele
@ 2009-09-21 21:19 ` Beckwith, Stephen (Stephen)
1 sibling, 0 replies; 16+ messages in thread
From: Beckwith, Stephen (Stephen) @ 2009-09-21 21:19 UTC (permalink / raw)
To: linux-arm-kernel
Greetings All,
As noted below, we experienced a problem on Linux 2.4.x kernels for ARM when running pthreads.
Thanks to Daniel @ CodeSourcery for assistance in getting my .so to link properly with my application.
My results are: I do NOT see the same problem as seen on the Linux 2.4.x kernel. When creating pthreads when calling a .so, they get created correctly and return to the "main" to continue execution.
The test platform is: ARM Realview EB with ARM11MPCore CoreTile using the "stock" ARM released 2.6.28 SMP built kernel.
We use real-time threads with FIFO ordering and set the priority as we define in our application so that everything works correctly.
Regards,
Stephen Beckwith
-----Original Message-----
From: linux-arm-kernel-bounces@lists.infradead.org [mailto:linux-arm-kernel-bounces at lists.infradead.org] On Behalf Of Beckwith, Stephen (Stephen)
Sent: Thursday, September 17, 2009 8:47 AM
To: schindele at nentec.de; linux-arm-kernel at lists.infradead.org
Cc: Eric Miao
Subject: RE: Problems with pthread on ARM/PXA270
Greetings All,
I will quickly add the following to this thread, as it seems related.
Platform:
Custom ARM9 SoC using Montavista Linux Release 3.1, a 2.4.21 Linux Kernel. Montavista tool chain and libraries.
Problem:
When we try and execute a pthread_create, "when loaded as a .so", the thread will be created, but will not "return" to the main thread for further processing, we basically get "stuck" in this new thread. In the "real" case, this is an ISR thread, would hang on waiting for an interrupt. For testing, I use Sleep and prints to document program flow.
However, IF I use the "exact same code" and build the program as an application, it works just fine dandy. . . The thread gets spawned, prints it's initial hello, then goes into the while (1) sleep/print incrementing value loop. The thread returns to the "Main" and we spawn 2 more threads and they work just fine (based upon interleaving printouts)
NOTE:
For our "normal" development we use an external host processor (PowerPC based) to control the SoC and the ability to create threads from a .so has worked in this setup (using same MVL 3.1 kernel/toolchain) for the past 4+ years on 10's of platforms. So we suspected some issue/problem with the MVL setup
Now, we are migrating to a new ARM11 based SoC and I am in the process of re-testing this functionality.
This new platform will be based upon 2.6.28 kernel release and CodeSourcery G++ Lite 2008q3-72 tools/libraries.
I'm in the process of setting this up on an ARM RealView EB.
Details to follow.
Regards,
Stephen Beckwith
-----Original Message-----
From: linux-arm-kernel-bounces@lists.infradead.org [mailto:linux-arm-kernel-bounces at lists.infradead.org] On Behalf Of Juergen Schindele
Sent: Thursday, September 17, 2009 3:36 AM
To: linux-arm-kernel at lists.infradead.org
Cc: Eric Miao
Subject: Re: Problems with pthread on ARM/PXA270
Am Mittwoch, 16. September 2009 schrieb Eric Miao:
> On Wed, Sep 16, 2009 at 11:01 PM, Juergen Schindele <schindele@nentec.de> wrote:
> > Am Mittwoch, 16. September 2009 schrieb Eric Miao:
> >> Don't remember we had such problems before. What kind of system
> >> and libraries are you using?
> > thanks for your reply.
> > System is custom PXA270 platform.
> > with codesourcery compiler (see below)
> > and glibc 2.5 with pthread.
> > I dont know what more information to give ?
>
> Like which kernel version, where do you get the glibc-2.5 and pthread binary,
Sorry forgot that completely !
Kernel version tested is 2.6.16 and 2.6.20 (sorry no newer version available yet)
Compiler , GlibC, pthread all come from Codesourcery precompiled in a package
"CodeSourcery Sourcery G++ Lite 2007q1-10" downloadable for free.
Compiler version is as mentioned before :
arm-none-linux-gnueabi-gcc (CodeSourcery Sourcery G++ Lite 2007q1-10) 4.2.0 20070413 (prerelease)
--------------------------------------------------------------
J?rgen Schindele
Software-Entwicklung
NENTEC Netzwerktechnologie GmbH
Greschbachstr. 12
76229 Karlsruhe
Deutschland
Telefon: +49 721 94249-51
Telefax: +49 721 94249-10
E-Mail: schindele at nentec.de
WEB: www.nentec.de
Gesch?ftsf?hrung: Klaus Becker, Roland Knapp
Sitz der Gesellschaft: Karlsruhe
Handelsregister: Amtsgericht Mannheim HRB 107658
--------------------------------------------------------------
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 16+ messages in thread
* Problems with pthread on ARM/PXA270
2009-09-16 7:26 Problems with pthread on ARM/PXA270 Juergen Schindele
2009-09-16 14:14 ` Eric Miao
@ 2009-09-16 14:40 ` Daniel Jacobowitz
2009-09-18 10:06 ` Juergen Schindele
2009-09-16 22:01 ` Jamie Lokier
` (2 subsequent siblings)
4 siblings, 1 reply; 16+ messages in thread
From: Daniel Jacobowitz @ 2009-09-16 14:40 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Sep 16, 2009 at 09:26:01AM +0200, Juergen Schindele wrote:
> Hello all,
> we tried to implement a thread based software on our PXA270 based platform but
> we had trouble with pthreads. So i modyfied a tiny progam to test. This little progam creates
> 10 threads and each thread does print something (an index an a pointer to itself).
>
> On my PC with Suse 11.0 Linux (kernel 2.6.27) this works fine as supposed to.
> Each thread has his turn and print his own values.
>
> But on our pxa270 platform the thread switch does not (or really rarely) happen
> and only one thread is printing always the same values. So i suppose thread
> switching is not working!
>
> Any hints or experiences are welcome !!!
It's just a wild guess, but check your sched_clock implementation. I
fixed a similar problem in QEMU last week; the kernel used to function
OK with sched_clock always returning zero, but some time between
2.6.25 and 2.6.28 became dependent on it.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 16+ messages in thread* Problems with pthread on ARM/PXA270
2009-09-16 14:40 ` Daniel Jacobowitz
@ 2009-09-18 10:06 ` Juergen Schindele
2009-09-18 14:10 ` Daniel Jacobowitz
0 siblings, 1 reply; 16+ messages in thread
From: Juergen Schindele @ 2009-09-18 10:06 UTC (permalink / raw)
To: linux-arm-kernel
Am Mittwoch, 16. September 2009 schrieb Daniel Jacobowitz:
> On Wed, Sep 16, 2009 at 09:26:01AM +0200, Juergen Schindele wrote:
> > Hello all,
> > we tried to implement a thread based software on our PXA270 based platform but
> > we had trouble with pthreads. So i modyfied a tiny progam to test. This little progam creates
> > 10 threads and each thread does print something (an index an a pointer to itself).
> >
> > On my PC with Suse 11.0 Linux (kernel 2.6.27) this works fine as supposed to.
> > Each thread has his turn and print his own values.
> >
> > But on our pxa270 platform the thread switch does not (or really rarely) happen
> > and only one thread is printing always the same values. So i suppose thread
> > switching is not working!
> >
> > Any hints or experiences are welcome !!!
>
> It's just a wild guess, but check your sched_clock implementation. I
> fixed a similar problem in QEMU last week; the kernel used to function
> OK with sched_clock always returning zero, but some time between
> 2.6.25 and 2.6.28 became dependent on it.
>
sched_clock is apparently not implemented the same way in all kernel versions.
What about thread implementation in codesourcery compiler ? Are they
"linux-threads" or "Native Posix thread library" or is it possible that there
are important bugfixes til the version i use ???
Is my example app. correct in programming or am i doing bloody beginners mistake there ??
Thanks for your help
--------------------------------------------------------------
J?rgen Schindele
Software-Entwicklung
NENTEC Netzwerktechnologie GmbH
Greschbachstr. 12
76229 Karlsruhe
Deutschland
Telefon: +49 721 94249-51
Telefax: +49 721 94249-10
E-Mail: schindele at nentec.de
WEB: www.nentec.de
Gesch?ftsf?hrung: Klaus Becker, Roland Knapp
Sitz der Gesellschaft: Karlsruhe
Handelsregister: Amtsgericht Mannheim HRB 107658
Diese E-Mail enth?lt vertrauliche oder rechtlich gesch?tzte Informationen.
Wenn Sie nicht der vorgesehene Empf?nger sind, informieren Sie bitte sofort
den Absender und l?schen Sie diese E-Mail. Das unbefugte Kopieren dieser E-Mail
oder die unbefugte Weitergabe der enthaltenen Informationen ist nicht gestattet.
The information contained in this message is confidential or protected by law.
If you are not the intended recipient, please contact the sender and delete this
message. Any unauthorised copying of this message or unauthorised distribution of
the information contained herein is prohibited.
--------------------------------------------------------------
^ permalink raw reply [flat|nested] 16+ messages in thread
* Problems with pthread on ARM/PXA270
2009-09-18 10:06 ` Juergen Schindele
@ 2009-09-18 14:10 ` Daniel Jacobowitz
0 siblings, 0 replies; 16+ messages in thread
From: Daniel Jacobowitz @ 2009-09-18 14:10 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Sep 18, 2009 at 12:06:59PM +0200, Juergen Schindele wrote:
> sched_clock is apparently not implemented the same way in all kernel versions.
> What about thread implementation in codesourcery compiler ? Are they
> "linux-threads" or "Native Posix thread library" or is it possible that there
> are important bugfixes til the version i use ???
NPTL in any recent version. I don't remember for the ancient version
you said you were using; consider an update.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 16+ messages in thread
* Problems with pthread on ARM/PXA270
2009-09-16 7:26 Problems with pthread on ARM/PXA270 Juergen Schindele
2009-09-16 14:14 ` Eric Miao
2009-09-16 14:40 ` Daniel Jacobowitz
@ 2009-09-16 22:01 ` Jamie Lokier
2009-09-16 22:54 ` [arm-gnu] " James
2009-09-24 8:34 ` Juergen Schindele
4 siblings, 0 replies; 16+ messages in thread
From: Jamie Lokier @ 2009-09-16 22:01 UTC (permalink / raw)
To: linux-arm-kernel
Juergen Schindele wrote:
> But on our pxa270 platform the thread switch does not (or really
> rarely) happen and only one thread is printing always the same
> values. So i suppose thread switching is not working!
What time quantum does sched_rr_get_interval() return? SCHED_RR is
only expected to switch that often.
-- Jamie
^ permalink raw reply [flat|nested] 16+ messages in thread
* [arm-gnu] Problems with pthread on ARM/PXA270
2009-09-16 7:26 Problems with pthread on ARM/PXA270 Juergen Schindele
` (2 preceding siblings ...)
2009-09-16 22:01 ` Jamie Lokier
@ 2009-09-16 22:54 ` James
2009-09-18 7:53 ` Uwe Kleine-König
2009-09-24 8:34 ` Juergen Schindele
4 siblings, 1 reply; 16+ messages in thread
From: James @ 2009-09-16 22:54 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
On Wed, 2009-09-16 at 09:26 +0200, Juergen Schindele wrote:
> we tried to implement a thread based software on our PXA270 based platform but
> we had trouble with pthreads. So i modyfied a tiny progam to test. This little progam creates
> 10 threads and each thread does print something (an index an a pointer to itself).
>
> On my PC with Suse 11.0 Linux (kernel 2.6.27) this works fine as supposed to.
> Each thread has his turn and print his own values.
>
> But on our pxa270 platform the thread switch does not (or really rarely) happen
> and only one thread is printing always the same values. So i suppose thread
> switching is not working!
>
> Any hints or experiences are welcome !!!
I'm not a very thread aware programmer so please don't shoot me, but I
was wondering, why would a thread give up control after printing its
values? Your program has them doing a tight loop with no sleep, or
yield.
I added a usleep(1) just after the printf("Thread...."), and the results
on my Linux Ubuntu-Desktop 2.6.24-24-generic #1 SMP Tue Aug 18 17:04:53
UTC 2009 i686 GNU/Linux are much better, but still not one message per
thread. I changed the usleep to a sched_yield() and got still better
results, but still not what I'd expect from RR.
So what does it look like on your Suse box? Do you get one message per
thread in turn? I.e.
Thread 0 is [...]
Thread 1 is [...]
Thread 2 is [...]
Thread 3 is [...]
etc.?
Or do you get, say, 100 messages from thread 0, then 100 from thread 1,
etc.?
Are you running with superuser privileges? My manpage tells me that
SCHED_RR is only available if run with superuser privileges.
Out of curiosity, I got rid of the printf in the thread, and added a
global array of ints, as in int counter[NUM_THREADS]; Then made the
threads increment their counter each loop, and got the main while loop
to print the counter values.
Without a sched_yield() or usleep() in the thread loop, the values
increase at a phenomenal rate. With a sched_yield() the values increase
at about 1/100th the speed.
I once had some interesting problems running a program with just two
threads, one doing I/O to an ISA bus, the other handling a socket
interface, on a dual core machine. To get more predictable performance,
I ended up building a single threaded program and using select for the
whole lot, thereby implementing my own scheduling policy, effectively.
In any case, I think there's more going on with threads than meets the
eye. IMHO, they're evil, and should be left for Bill's programmers, who
are sadly bound to using them due to the lack of better ways on that
platform ;-)
Regards,
James.
^ permalink raw reply [flat|nested] 16+ messages in thread* [arm-gnu] Problems with pthread on ARM/PXA270
2009-09-16 22:54 ` [arm-gnu] " James
@ 2009-09-18 7:53 ` Uwe Kleine-König
2009-09-18 12:48 ` Jamie Lokier
0 siblings, 1 reply; 16+ messages in thread
From: Uwe Kleine-König @ 2009-09-18 7:53 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Sep 17, 2009 at 08:54:44AM +1000, James wrote:
> Are you running with superuser privileges? My manpage tells me that
> SCHED_RR is only available if run with superuser privileges.
Note that pthread_attr_setschedpolicy has a return value that tells you
if the function was successful.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 16+ messages in thread
* [arm-gnu] Problems with pthread on ARM/PXA270
2009-09-18 7:53 ` Uwe Kleine-König
@ 2009-09-18 12:48 ` Jamie Lokier
0 siblings, 0 replies; 16+ messages in thread
From: Jamie Lokier @ 2009-09-18 12:48 UTC (permalink / raw)
To: linux-arm-kernel
Uwe Kleine-K?nig wrote:
> On Thu, Sep 17, 2009 at 08:54:44AM +1000, James wrote:
> > Are you running with superuser privileges? My manpage tells me that
> > SCHED_RR is only available if run with superuser privileges.
> Note that pthread_attr_setschedpolicy has a return value that tells you
> if the function was successful.
And that SCHED_RR has a time quantum returned by sched_rr_get_interval
which is not guaranteed to be small. However, if it is a small time
and it's not switching that's a bug in either libc or the kernel.
Note that printf() does locking which may complicate things. Try
opening separate outputs for each thread, or using write().
-- Jamie
^ permalink raw reply [flat|nested] 16+ messages in thread
* Problems with pthread on ARM/PXA270
2009-09-16 7:26 Problems with pthread on ARM/PXA270 Juergen Schindele
` (3 preceding siblings ...)
2009-09-16 22:54 ` [arm-gnu] " James
@ 2009-09-24 8:34 ` Juergen Schindele
4 siblings, 0 replies; 16+ messages in thread
From: Juergen Schindele @ 2009-09-24 8:34 UTC (permalink / raw)
To: linux-arm-kernel
Am Mittwoch, 16. September 2009 schrieb Juergen Schindele:
Hey all,
i've done some tests on different platforms
running OK on x86 openSuse 11.0
- SCHED_OTHER OK
- SCHED_RR OK
on pxa270 (xscale) platform
compiler gcc 4.2.0
with glibc 2.5 (NPTL) from CodeSourcery
Sourcery G++ Lite 2007q1-10
on Kernel 2.6.20
- SCHED_OTHER works fine
- SCHED_RR does not work at all
on the same pxa270 (xscale) platform
compiler gcc 4.3.3
and glibc 2.8 (NPTL) from CodeSourcery
Sourcery G++ Lite 2009q1-203
Kernel 2.6.20
- SCHED_OTHER only one thread is running all the time
other threads are blocked.
- SCHED_RR does not work at all
on ixp425 (xscale) platform
compiler 3.3.2
with glibc 2.2.5 (not NPTL)
from uclinux
kernel 2.6.16
- SCHED_OTHER
First no thread are running. 30 minutes after starting the test all threads
are started and running. It's unbeleivable !!.
-SCHED_RR does not work at all
Why is SCHED_RR only running on x86 platform ???
Where is the difference in handling between SCHED_RR ans SCHED_OTHER ?
Any comments or helps ????
> Hello all,
> we tried to implement a thread based software on our PXA270 based platform but
> we had trouble with pthreads. So i modyfied a tiny progam to test. This little progam creates
> 10 threads and each thread does print something (an index an a pointer to itself).
>
> On my PC with Suse 11.0 Linux (kernel 2.6.27) this works fine as supposed to.
> Each thread has his turn and print his own values.
>
> But on our pxa270 platform the thread switch does not (or really rarely) happen
> and only one thread is printing always the same values. So i suppose thread
> switching is not working!
>
> Any hints or experiences are welcome !!!
>
> we use codesourcery compiler
> arm-none-linux-gnueabi-gcc (CodeSourcery Sourcery G++ Lite 2007q1-10) 4.2.0 20070413 (prerelease)
> Copyright (C) 2007 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> and here the C-code compiled with "arm-none-linux-gnueabi-gcc -o test test.c -lpthread"
>
> #include <errno.h>
> #include <error.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <pthread.h>
> #include <time.h>
>
> #define NUM_THREADS 10
> #define NUM_ITERS 50
> #define TIMEOUT_NS 100000000L
>
> static void *thread (void *);
> static int argument[NUM_THREADS];
> static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
> static pthread_attr_t defaultattr;
>
> static void * print_thread (void *arg)
> {
> int i;
> int number = *((int*)arg);
>
> for (;;) {
> pthread_t self = pthread_self ();
> printf ("Thread %d is [%d]\n", number, self);
> }
> }
>
> int main (void)
> {
> pthread_t th;
> int i, retvalue;
>
> struct sched_param param;
> pthread_attr_init(&defaultattr);
>
> pthread_attr_setschedpolicy(&defaultattr, SCHED_RR);
>
> param.sched_priority = 10;
> if ((retvalue = pthread_attr_setschedparam(&defaultattr, ¶m))!=0) {
> printf ("ERROR\n");
> exit (0);
> }
>
> for (i = 0; i < NUM_THREADS; i++)
> {
> argument[i] = i;
> if (pthread_create (&th, &defaultattr, print_thread, &argument[i]) != 0)
> error (EXIT_FAILURE, 0, "cannot create thread");
> printf ("Thread [%d]\n", i);
> }
>
> while (1) {
> ;
> }
>
> /* notreached */
> return 0;
> }
>
> --------------------------------------------------------------
> J?rgen Schindele
> Software-Entwicklung
>
> NENTEC Netzwerktechnologie GmbH
> Greschbachstr. 12
> 76229 Karlsruhe
> Deutschland
> Telefon: +49 721 94249-51
> Telefax: +49 721 94249-10
> E-Mail: schindele at nentec.de
> WEB: www.nentec.de
>
> Gesch?ftsf?hrung: Klaus Becker, Roland Knapp
> Sitz der Gesellschaft: Karlsruhe
> Handelsregister: Amtsgericht Mannheim HRB 107658
> --------------------------------------------------------------
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
>
--
--------------------------------------------------------------
J?rgen Schindele
Software-Entwicklung
NENTEC Netzwerktechnologie GmbH
Greschbachstr. 12
76229 Karlsruhe
Deutschland
Telefon: +49 721 94249-51
Telefax: +49 721 94249-10
E-Mail: schindele at nentec.de
WEB: www.nentec.de
Gesch?ftsf?hrung: Klaus Becker, Roland Knapp
Sitz der Gesellschaft: Karlsruhe
Handelsregister: Amtsgericht Mannheim HRB 107658
--------------------------------------------------------------
^ permalink raw reply [flat|nested] 16+ messages in thread