On Mon, 31 Oct 2005, David Xu wrote: > In thread program, we have to use clock_gettime, for example a thread > wants to wait for condition variable for two seconds, it has to: > > struct timespec ts; > > clock_gettime(CLOCK_REALTIME, &ts); > ts.tv_sec += 2; > pthread_cond_wait(&cond, &mtx); > > problem is who really cares time precise? how many people are really > handling realtime critical tasks? this is really an unpleasant side > effect that a simple syscall can stall cpu. The questions are: how good is good enough? And for what? The problem here is that while pthread_cond_wait() can afford to accept low resolution, the same clock retrieval interface is also used for things like scientific measurement. So it sounds like the real mistake was the specification for the thread API: while timespec is the New Way for time-related interfaces, this approach has coalesced precision time measurement and "how long to sleep for" time measurement. Moving to HZ incrementing of the clock probably exceeds the quality reduction that makes sense for clock_gettime(), but moving to a roughly sync'd TSC clock (such as the Linux approach) probably doesn't. Robert N M WatsonReceived on Mon Oct 31 2005 - 09:53:46 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:46 UTC