Opened 4 years ago

Last modified 11 months ago

#15615 new enhancement

pthread_getcpuclockid support

Reported by: kallisti5 Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: System/libroot.so Version: R1/Development
Keywords: pthread Cc:
Blocked By: Blocking:
Platform: All

Description

Seems to exist on all platforms and BSD's except Apple.

Here's an example usage from Mesa:

/* Return the time of a thread's CPU time clock. */
static inline int64_t
u_thread_get_time_nano(thrd_t thread)
{
#if defined(HAVE_PTHREAD) && !defined(__APPLE__)
   struct timespec ts;
   clockid_t cid;

   pthread_getcpuclockid(thread, &cid);
   clock_gettime(cid, &ts);
   return (int64_t)ts.tv_sec * 1000000000 + ts.tv_nsec;
#else
   return 0;
#endif
}

Change History (5)

comment:1 by pulkomandy, 4 years ago

One can use get_thread_info() and sum the user_time and kernel_time in the returned struct to get the equivalent on Haiku. We have only microsecond resolution, however.

comment:2 by nephele, 12 months ago

This is also required for mpv.

comment:3 by nephele, 12 months ago

Haiku exposes that we support this with _POSIX_THREAD_CPUTIME in posix/unistd.h

We should probably remove this from the file untill we have implemented it?

comment:4 by cocobean, 11 months ago

NOTE: This is not required for POSIX nor UNIX 2003 compatibility/compliance. We can close this ticket as it is not a bug/nor considered implemented yet.

comment:5 by pulkomandy, 11 months ago

Type: bugenhancement

That makes it an enhancement but there is no need to close it...

Also nephele is correct that we have a define in unistd.h announcing that we support it when that isn't the case, so at least that define should be removed.

Last edited 11 months ago by pulkomandy (previous) (diff)
Note: See TracTickets for help on using tickets.