Opened 5 years ago

Closed 6 days ago

#15615 closed enhancement (fixed)

pthread_getcpuclockid support

Reported by: kallisti5 Owned by: nobody
Priority: normal Milestone: R1/beta6
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 (8)

comment:1 by pulkomandy, 5 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, 20 months ago

This is also required for mpv.

comment:3 by nephele, 20 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, 19 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, 19 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 19 months ago by pulkomandy (previous) (diff)

comment:7 by korli, 6 days ago

Merged in hrev58421

comment:8 by korli, 6 days ago

Milestone: UnscheduledR1/beta6
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.