Re: Slow pthread_create() under high load

From: yodaiken@fsmlabs.com
Date: Tue Mar 28 2000 - 15:20:40 EST


On Tue, Mar 28, 2000 at 12:06:12PM -0800, David Schwartz wrote:
>
> > Can someone tell me why:
> >
> > pthread_creat( ....)
> > if this is the first created thread
> > rootpid = getpid();
> > redefine getpid === return rootpid
> >
> > Doesn't work?
>
> Define 'work'. 'getpid' is hardly the only function that uses pids. What
> about 'getppid'? As but one example, consider the following code:

Fork certainly complicates and since we don't allow fork in our realtime
pthreads environment, it did not occur to me. But surely this is no
biggie: fork must reset the cached value in getpid. The child forked process
is single threaded and until the first new thread is created, getpid can
be getpid.

> pid_t pid=getpid(); /* This gets the pid of the original thread, not this
> one */
> fork();
> if(getppid()==pid)
> {
> /* I must be the child */
> /* But wait, am I really? */
> }
>
> DS

-- 
---------------------------------------------------------
Victor Yodaiken 
FSMLabs:  www.fsmlabs.com  www.rtlinux.com
FSMLabs is a servicemark and a service of 
VJY Associates L.L.C, New Mexico.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Mar 31 2000 - 21:00:22 EST