pthread

Joel Sherrill joel.sherrill at OARcorp.com
Thu Mar 7 15:24:06 UTC 2002



Pattara Kiatisevi wrote:
> 
> Thank you for the answer.
> 
> Seems that the "default" priority is set something weird?

Look at the default structure before you run very far.  I
suspect you are overwriting it.

I have (quickly) doublechecked the pre-initialized structure 
for default attributes in pthread.c and don't see where
it doesn't match field for field and is initialized
correctly.  So that leads me to believe it is corrupted
by execution.  

> -----------------------------------------------------------------
> 285         task_ret = pthread_create(&audioPlay, NULL, (void *)
> playAudioTask, (void *) &taskparameter);(gdb) s
> pthread_create (thread=0x403f7d70, attr=0x0, start_routine=0x4000187c
> <playAudioTask>, arg=0x403f7d68)
>     at ../../../../../../../c/src/exec/posix/src/pthreadcreate.c:41
> 41        the_attr = (attr) ? attr : &_POSIX_Threads_Default_attributes;
> (gdb) n
> 43        if ( !the_attr->is_initialized )
> (gdb) print the_attr
> $1 = (pthread_attr_t *) 0x4005dc80
> (gdb) n
> 51        if ( the_attr->stackaddr && !_Stack_Is_enough(
> the_attr->stacksize ) )
> (gdb) n
> 70            api = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
> (gdb) n
> 72            schedparam  = api->schedparam;
> (gdb) n
> 71            schedpolicy = api->schedpolicy;
> (gdb) n
> 72            schedparam  = api->schedparam;
> (gdb)
> 73            break;
> (gdb)
> 89        if ( the_attr->contentionscope != PTHREAD_SCOPE_PROCESS )
> (gdb)
> 20        return (boolean) (priority >= 1 && priority <= 254);
> (gdb)
> 96        if ( !_POSIX_Priority_Is_valid( schedparam.sched_priority ) )
> (gdb)
> 235         return EINVAL;
> (gdb) print schedparam
> $2 = {sched_priority = 1073764644, ss_low_priority = 8217,
> ss_replenish_period = {tv_sec = 1077899424,
>     tv_nsec = 1074035684}, ss_initial_budget = {tv_sec = 0, tv_nsec = 0}}
> (gdb) print schedparam.sched_priority
> $3 = 1073764644
> (gdb) n
> 247     }
> (gdb)
> Init (ignored=0) at player.c:286
> 286         if (task_ret) {
> (gdb) print task_ret
> $4 = 22
> 
> Pattara
> --
> Please avoid sending me Word or PowerPoint attachments.
> See http://www.fsf.org/philosophy/no-word-attachments.html
> ----------------------------------------------------------------------
> Ott Pattara Kiatisevi                              T L W G
> M.Sc. INFOTECH Student, Stuttgart, Germany      http://linux.thai.net/
> ----------------------------------------------------------------------
> 
> On Thu, 7 Mar 2002, Joel Sherrill wrote:
> 
> >
> >
> > Pattara Kiatisevi wrote:
> > >
> > > Hi,
> > >
> > > I'm writing a pthread program. In the header I have:
> > >
> > > #define CONFIGURE_MAXIMUM_POSIX_THREADS 5
> > > #define CONFIGURE_MAXIMUM_POSIX_MUTEXES 5
> > > #define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 5
> > >
> > > Then in Init() I have sth. like:n
> > >
> > >  {
> > >     int task_ret;
> > >     task_ret = pthread_create(&audioPlay, NULL, (void *) playAudioTask,
> > > (void *) &taskparameter);
> > >     if (task_ret) {
> > >       perror("pthread_create: playAudioTask");
> > >       exit(EXIT_FAILURE);
> > >     }
> > >   }
> > >
> > > The program exited with task_ret = 22. Anybody has the idea what this "22"
> > > means? Do I have to set any #define more in order to have pthread function
> > > worked?
> >
> >
> > You probably want to use strerror or perror on the exit paths.  But
> > see /opt/rtems/CPU-rtems/include/sys/errno.h for the mapping.  This
> > is EINVAL.  Unfortunately, that is a catch all error in in POSIX.
> > The only real error it doesn't cover is not configuring enough
> > pthreads.  I hate to suggest this but you would be better off
> > tracing into the call or at least reading the pthreadcreate.c
> > source and see if something rings a bell.   Here is the URL
> > for the man page which lists the conditions for EINVAL:
> >
> > http://www.oarcorp.com/rtemsdoc-4.5.1-pre3/rtemsdoc/html/posix_users/posix_users00344.html
> >
> > > Thank you very much,
> >
> > POSIX makes figuring out what is wrong with a call tough.
> > I don't see anything obvious myself.
> >
> > > Pattara
> > >
> > > --
> > > Please avoid sending me Word or PowerPoint attachments.
> > > See http://www.fsf.org/philosophy/no-word-attachments.html
> > > ----------------------------------------------------------------------
> > > Ott Pattara Kiatisevi                              T L W G
> > > M.Sc. INFOTECH Student, Stuttgart, Germany      http://linux.thai.net/
> > > ----------------------------------------------------------------------
> >
> > --
> > Joel Sherrill, Ph.D.             Director of Research & Development
> > joel at OARcorp.com                 On-Line Applications Research
> > Ask me about RTEMS: a free RTOS  Huntsville AL 35805
> > Support Available                (256) 722-9985
> >
> >

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel at OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985



More information about the users mailing list