POSIX clock_gettime(), clock_settime(), and clock_getres() and time.h
POSIX clock_gettime(), clock_settime(), and clock_getres() and time.h
- Subject: POSIX clock_gettime(), clock_settime(), and clock_getres() and time.h
- From: Bayard Bell <email@hidden>
- Date: Fri, 06 May 2011 12:01:12 +0100
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I'm looking to port some software from Linux and have discovered that it uses the POSIX clock_gettime() function to get thread-level data on the time spent on CPU. The group of functions and macros are all from the Timer subset of POSIX.1-2003, which is optional, but become part of the C extensions definition that is mandatory in POSIX.1-2008. From what I gather, OS X has the functionality to support the following clock_ids under the POSIX definition:
CLOCK_MONOTONIC
CLOCK_REALTIME
_POSIX_CPUTIME
_POSIX_THREAD_CPUTIME
All of these have microsecond resolution, and some have nanosecond resolution. The problem is largely that OS X doesn't present the functionality through POSIX interfaces, but the information necessary to roll your own can be gleaned from documentation and the open source parts of Darwin. I'm not the first person to notice this, and there appear to be a few places where people have implemented at least parts of these interfaces as wrappers.
So the first question is whether anyone knows if Lion is meant to be POSIX.1-2008 compliant, such that there should be a clean way to support this on a POSIX-compliant, Apple-provided interface going forward. I don't know the history in FreeBSD, but the functions are present there now as system calls, which might be an indication that these functions will be ported as OS X is updated against FreeBSD before there's even a question of POSIX.
Looking backwards: as far as porting to Leopard and Snow Leopard, can anyone recommend an existing set of wrappers for the subset of functionality previously identified?
I hope I'm not rehashing previous discussions. I did some googling, and the only thing I got was references to others writing wrappers and various bits of POSIX.1 definitions, which I've attempted to summarise above.
Cheers,
Bayard
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.12 (Darwin)
iQIcBAEBAgAGBQJNw9UHAAoJEHm5cBpJ87dokv0P/09rmOsPlUdLM5Gr//WRA1Qi
5qTDCgNpXY8qbjNjB6SWyrHdBkPod2o8yxg1kHb1tWp2vNugQRqjBpMi7gOxQR1/
t5sfpL3ePg3drJScjDWe/iQfFexJxaMgBJ1dt75ne/RQxCQHqkjv0XCssWT9EM6C
X6ldMLQDRUOeexsmcoo+0F9XD2iG9Q+tJS11HtQ062/bO3tghZYPttHaNmiQCZTn
iGnHL6dp2ga2m09zPsdOHMo78BcSTxejdAQgwNOwr8vsy5UHZ7Kw+CGLV3yguSf/
qZ9Kz6lrD3A99RFfbLG7ORPUZ029rJsRVDD9TKOQH4zCOkyEaO3GCB2XxETA6ANY
C29VCbTvQ2/a7nFZnp9s9Uvj75aT2dODin8UorwR65dhjgj7Frb5JTj1ZCx7Kyjf
FEEKxpzjRdOHmo3xGvVeR17XgdLhh7Nzl8/KmKc4YTf1xLY95EO5AyHIRhIcL56i
I3qRxtJoc4H5b3PvKxejodbUC0T/Sj+nW5f2Y5TnxrXC6Oole3COMzewFPi1bDzi
epOouzjxjNFqWj4/IwiSL8hriTDwK1klXmARg/NCkR/qBE+BQYnLjP556Qd0Z8v0
UbPQO8YdJ8AWYHH/zWrtNvWch4pn2Omfdo0ROxRZ2t0EJm/fn3JpdS3e4c/lNqfH
yY0QQETbPWD0RFweyTlS
=FWDQ
-----END PGP SIGNATURE-----
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden