This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: POSIX thread problem


On Sun, Sep 25, 2005 at 11:51:08PM -0700, Kaushik karandikar wrote:
> Hi All,
>         I want to create a new thread using
> pthread_create() function. I have added the package
> POSIX compatibility. But i am not getting the prints
> in the thread function.
> 
> My code snippet :
> 
> #include <cyg/kernel/kapi.h>
> #include<cyg/posix/semaphore.h>
> #include<cyg/posix/pthread.h>
> #include<cyg/posix/types.h>
>                                                       
>                                           
>                                                       
>                                          void
> *thread_func(void *arg)
> {
>   while(1)
>     {
>         cyg_thread_delay(5);
>        diag_printf("\n\nIn thread Function....\n\n");
> 
>     }
> }
> void cyg_start()
>  {
>    int res;
>    pthread_t a_thread;
>    void *thread_result;
> //   pthread_attr_t attr;
>                                                       
>                                           
> //   attr.stacksize = 4096;
> //   attr.detachstate=PTHREAD_CREATE_JOINABLE;
> //   attr.schedpolicy=SCHED_RR;
> //   attr.inheritsched=PTHREAD_INHERIT_SCHED;
>                                                       
>                                           
> 
> //      pthread_attr_init(&attr);
> //    res =
> pthread_create(&a_thread,&attr,thread_func,NULL);
>       res =
> pthread_create(&a_thread,NULL,thread_func,NULL);
>       if(res != 0)
>         {
>                 diag_printf("\nThread Creation 
> failed....\n");
>         }
>                                                       
>                                           
>                 diag_printf("\ncalling
> thread_func....\n");
>                                                       
>                                           
>    cyg_scheduler_start();
> }
> 
> Is there any othe package that need to be added in the
> eCOS to make work the POSIX compliant thread and
> semaphire calls?

It is better to use the poosix template.

ecosconfig new ebsa285 posix

        Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]