Posix Threads, pthreads?

sashti srinivasan svasn_rtems at yahoo.com
Sat Feb 21 09:18:08 UTC 2004


Hello,
   Thanks a lot.  I could run this example on both
linux and rtems both. I built rtems with
--enable-posix option, still if I do grep in
$(install)/$(bsp)/lib, none of the libraries contain
pthread_create.  If I use this and run the makefile
that is provided here for guidance, still I get the
error complaining "undefined reference to
pthread_create".  My target platform is linux.  i.e.,
I built rtems without --target option.

    I could get away this option with an additional
-lpthread switch in linkflags.  I doubt that it will
be using host's pthread-library in this case.  Please
help me in going about.

Regards
Srinivasan

--- Joel Sherrill <joel.sherrill at OARcorp.com> wrote:
> sashti srinivasan wrote:
> 
> > Hello All,
> > 
> >      I want to write my program in such a way that
> > same code can be run as both rtems application and
> as
> > a linux application.  Ofcourse, I will make small
> > changes like main() instead of Init() etc. 
> Towards
> > this end, I want to use pthread_create instead of
> > rtems_task_create/start.  But the linker complains
> > saying that pthread_create not found.  I searched
> all
> > the .a files in $(prefix)/$(bsp)/lib and could not
> > find pthread_create.  Please tell me how to use
> > pthreads.
> 
> It sounds line you did not configure with
> --enable-posix
> and it wasn't built.
> 
> You will have to provide an RTEMS configuration
> table
> but otherwise, there CAN be very little difference
> between
> the Linux and RTEMS versions of the application.
> 
> Just to help you get started, the following is a
> POSIX
> hello world that will will run on Linux and RTEMS. 
> And
> although Ralf doesn't like them :), I included a
> small
> application Makefile.
> 
> =================================================
> 
> #include <stdio.h>
> 
> int main(int argc, char **argv)
> {
>    printf( "hello world\n" );
>    exit(0);
> }
> 
> /*
>   *  The following instantiates the RTEMS
> Configuration Information
>   *  and has to be tailored for the application.
>   */
> 
> #if defined(__rtems__)
> #include <rtems.h>
> 
> #define CONFIGURE_POSIX_INIT_THREAD_TABLE
> #define CONFIGURE_POSIX_INIT_THREAD_ENTRY_POINT
> (void*)main
> 
> #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
> 
> #define CONFIGURE_MAXIMUM_POSIX_THREADS 1
> 
> #define CONFIGURE_INIT
> 
> #include <confdefs.h>
> #endif
> =================================================
> #
> #  Makefile
> #
> 
> include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
> 
> include $(RTEMS_CUSTOM)
> include $(PROJECT_ROOT)/make/leaf.cfg
> 
> all:    hello
> 
> hello: hello.c
>          $(CC_FOR_TARGET)  $(GCCSPECS) $(CPU_CFLAGS)
> -o hello hello.c
> 
> clean:
>          rm -f *.o hello
> =================================================
> 
> Note that you might have to done something after the
> link
> command to convert to a downloadable format.
> 
> >      One more doubt.  Instead of using the
> traditional
> > makefile distributed with example applications, I
> have
> > made my own (from whatever appeared on the console
> > while running make on the distributed makefile). 
> This
> > also works fine.  During link time, if we link
> with
> > some .rel files, some of the directives do not
> work. 
> > Please explain me what are these .rel files.  I am
> > sorry if it is a trivial doubt.  In this case,
> please
> > give me pointers about this.
> 
> The .rel's sound like the optional manager stubs. 
> If
> you link against them, you will get dummy versions
> of
> those managers which return an error for every call.
> 
> >      One help please.  I want to write a
> performance
> > suite (similar to tmtests distributed) for rtems
> and
> > for linux and wish to compare them.  If such an
> > activity is already done, please give me pointers
> and
> > source codes.  Also guide me if some comparative
> > analysis of rtems and other OS like uClinux,
> RTlinux,
> > eCos, RTAI etc. is reported somewhere.
> > 
> > With Regards
> > Srinivasan
> > 
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Mail SpamGuard - Read only the mail you
> want.
> > http://antispam.yahoo.com/tools
> 
> 


__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools



More information about the users mailing list