Re: system call library functions
Dow Street <[email protected]>
| Newsgroups | gmane.os.opendarwin.general |
|---|---|
| Message-ID | <[email protected]> |
Thanks, all! (Shantonu, Rob, and Justin) R, Dow On Nov 29, 2004, at 1:17 PM, Justin Walker wrote: > > On Nov 29, 2004, at 13:06, Dow Street wrote: > >> All, >> >> I am writing some benchmarking code for OS X 10.3.5. When using >> getpid() to measure the overhead of a system call, I find the >> overhead to be much less than expected (1-3 clicks on the MPC 7447a >> TBR). When making the call using syscall(20), however, the >> measurement is as expected (~33 clicks on the TBR). Is getpid >> actually using a library function which retrieves the PID from a user >> space data structure (without entry into the kernel?) Any idea what >> / where this function is located and the data structure it's >> accessing? > > The first call to getpid() goes to the kernel; subsequent calls > retrieve the pid cached in user space (since a process's PID doesn't > change from moment to moment). That's a bit of a simplification, but > check the source. > > Cf the file Libc/ppc/sys/getpid.s > > Regards, > > Justin > > -- > Justin C. Walker, Curmudgeon-At-Large * > Institute for General Semantics | If you're not confused, > | You're not paying attention > *-------------------------------------- > *-------------------------------* > > _______________________________________________ > Discuss mailing list > [email protected] > http://www.opendarwin.org/mailman/listinfo/discuss >