Messages in this thread | | | Date | Tue, 28 Mar 2000 13:20:40 -0700 | From | yodaiken@fsmlabs ... | Subject | Re: 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/
| |