On Mon, Nov 08, 2010 at 03:37:03PM -0800, john stultz wrote:
Yes, you are right, of course, but I would like to point out that the
existing "overloading" of the clockid_t isn't really explained at all.
It was not clear to me whether or not 29 pid bits is enough for the
worst case, or not.
This code is older than 2005 (git/linux) and so I don't know who wrote
it and what they were thinking. I took the first step and tried to
explain as much I understand.
I also didn't see any limit to the number of open files, except that
it must be a non-negative (signed) integer.
For userspace, there will have to be a glibc function/macro like
FD_TO_CLOCKID() that tests the three most significant bits and returns
CLOCK_INVALID if any are set.
This will result in the limitation that if a userspace program already
has 2^29 (536 million) open files, then it will not be able to obtain
a dynamic clock id. I think we can live with that.
Actually, what I would like to do is refactor the exisiting posix
clock code to use the new framework. The idea is to have a set of
static global clock_device*, one per fixed clock. The function
clockid_to_clock_device() will include a lookup table, like this:
static clock_device *realtime_clock, *monotinic_clock;
switch (id) {
case CLOCK_REALTIME:
return realtime_clock;
case CLOCK_MONOTONIC:
return monotinic_clock;
/* and so on ... */
}
This could be done on top of the existing patch in an incremental way.
However, I did not want to change everything all at once.
Sorry to disagree, but I really don't want to be the one to extend
that macro in any way. IMHO it really should be replaced with
something more legible.
Thanks for the review,
Richard
--