lkml.org 
[lkml]   [2000]   [Mar]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Slow pthread_create() under high load
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/

\
 
 \ /
  Last update: 2005-03-22 13:57    [W:0.076 / U:0.168 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site