This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: POSIX thread problem
- From: Andrew Lunn <andrew at lunn dot ch>
- To: Kaushik karandikar <kaushikkarandikar at yahoo dot com>
- Cc: ecos-discuss at ecos dot sourceware dot org
- Date: Mon, 26 Sep 2005 09:16:51 +0200
- Subject: Re: [ECOS] POSIX thread problem
- References: <20050926065108.82103.qmail@web30615.mail.mud.yahoo.com>
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