speed up threaded fork
authorRich Felker <dalias@aerifal.cx>
Tue, 12 Apr 2011 21:52:14 +0000 (17:52 -0400)
committerRich Felker <dalias@aerifal.cx>
Tue, 12 Apr 2011 21:52:14 +0000 (17:52 -0400)
after fork, we have a new process and the pid is equal to the tid of
the new main thread. there is no need to make two separate syscalls to
obtain the same number.

src/process/fork.c

index 012b7ca59c0bb681df3715ff9c6a587870f18a1c..07fb79ed4d361560e272c5f111a7e468539cfda8 100644 (file)
@@ -10,8 +10,7 @@ pid_t fork(void)
        ret = syscall(SYS_fork);
        if (libc.lock && !ret) {
                pthread_t self = __pthread_self();
-               self->pid = syscall(SYS_getpid);
-               self->tid = syscall(SYS_gettid);
+               self->tid = self->pid = syscall(SYS_getpid);
                libc.threads_minus_1 = 0;
        }
        if (libc.fork_handler) libc.fork_handler(!ret);