Ticket #3891: 0001-pthreadgetcpuclockid.c-Implement-pthread_getcpuclock.patch
File 0001-pthreadgetcpuclockid.c-Implement-pthread_getcpuclock.patch, 1.6 KB (added by Joel Sherrill, on 04/03/20 at 17:41:53) |
Untested implementation of pthread_getcpuclockid() assuming thread ID is used as the per thread cpu clock id. Needs clock_gettime/clock_settime capabilities added and tests
|
-
From d2427f7091dbf6e50ee8d4cf21c5c7cb08467ce8 Mon Sep 17 00:00:00 2001
From: Joel Sherrill <joel@rtems.org>
Date: Thu, 12 Mar 2020 14:59:51 -0500
Subject: [PATCH] pthreadgetcpuclockid.c: Implement pthread_getcpuclockid to
return thread Id
Updates #3891.
---
cpukit/posix/src/pthreadgetcpuclockid.c | 31 ++++++++++++++++++++++++++-----
1 file changed, 26 insertions(+), 5 deletions(-)
diff --git a/cpukit/posix/src/pthreadgetcpuclockid.c b/cpukit/posix/src/pthreadgetcpuclockid.c
index cd7814b..c15962e 100644
a
|
b
|
|
7 | 7 | |
8 | 8 | /* |
9 | 9 | * 20.1.6 Accessing a Thread CPU-time Clock, P1003.4b/Draft 8, p. 58 |
10 | | * |
11 | | * COPYRIGHT (c) 1989-2007. |
| 10 | */ |
| 11 | |
| 12 | /* |
| 13 | * COPYRIGHT (c) 1989-2007,2020. |
12 | 14 | * On-Line Applications Research Corporation (OAR). |
13 | 15 | * |
14 | 16 | * The license and distribution terms for this file may be |
… |
… |
|
23 | 25 | #include <pthread.h> |
24 | 26 | #include <errno.h> |
25 | 27 | |
26 | | #include <rtems/seterr.h> |
| 28 | #include <rtems/score/threadimpl.h> |
27 | 29 | |
28 | 30 | int pthread_getcpuclockid( |
29 | | pthread_t pid, |
| 31 | pthread_t thread, |
30 | 32 | clockid_t *clock_id |
31 | 33 | ) |
32 | 34 | { |
33 | | rtems_set_errno_and_return_minus_one( ENOSYS ); |
| 35 | Thread_Control *the_thread; |
| 36 | ISR_lock_Context lock_context; |
| 37 | |
| 38 | if ( clock_id == NULL ) { |
| 39 | return EINVAL; |
| 40 | } |
| 41 | |
| 42 | the_thread = _Thread_Get( thread, &lock_context ); |
| 43 | |
| 44 | if ( the_thread == NULL ) { |
| 45 | return ESRCH; |
| 46 | } |
| 47 | |
| 48 | _Thread_State_acquire_critical( the_thread, &lock_context ); |
| 49 | |
| 50 | *clock_id = the_thread->Object.id; |
| 51 | |
| 52 | _Thread_State_release( the_thread, &lock_context ); |
| 53 | |
| 54 | return 0; |
34 | 55 | } |
Download in other formats: