[PATCH] pthreadgetcpuclockid.c: Implement pthread_getcpuclockid to return thread Id

Gedare Bloom gedare at rtems.org
Sun Apr 5 14:58:15 UTC 2020


On Sun, Apr 5, 2020 at 4:02 AM Eshan Dhawan <eshandhawan51 at gmail.com> wrote:
>
> Is this patch pushed?
vim cpukit/posix/src/pthreadgetcpuclockid.c +7

Doesn't look like it.

> where will its test be added?
Sounds like work to be done. Based on other patterns, there should be a
psxtests/psxgetcpuclockid01
added.

> :)
>
> thanks
> - Eshan
>
> On Fri, Mar 13, 2020 at 1:30 AM Joel Sherrill <joel at rtems.org> wrote:
>>
>> ---
>>  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/cpukit/posix/src/pthreadgetcpuclockid.c
>> +++ b/cpukit/posix/src/pthreadgetcpuclockid.c
>> @@ -7,8 +7,10 @@
>>
>>  /*
>>   *  20.1.6 Accessing a Thread CPU-time Clock, P1003.4b/Draft 8, p. 58
>> - *
>> - *  COPYRIGHT (c) 1989-2007.
>> + */
>> +
>> +/*
>> + *  COPYRIGHT (c) 1989-2007,2020.
>>   *  On-Line Applications Research Corporation (OAR).
>>   *
>>   *  The license and distribution terms for this file may be
>> @@ -23,12 +25,31 @@
>>  #include <pthread.h>
>>  #include <errno.h>
>>
>> -#include <rtems/seterr.h>
>> +#include <rtems/score/threadimpl.h>
>>
>>  int pthread_getcpuclockid(
>> -  pthread_t    pid,
>> +  pthread_t    thread,
>>    clockid_t   *clock_id
>>  )
>>  {
>> -  rtems_set_errno_and_return_minus_one( ENOSYS );
>> +  Thread_Control               *the_thread;
>> +  ISR_lock_Context              lock_context;
>> +
>> +  if ( clock_id == NULL ) {
>> +    return EINVAL;
>> +  }
>> +
>> +  the_thread = _Thread_Get( thread, &lock_context );
>> +
>> +  if ( the_thread == NULL ) {
>> +    return ESRCH;
>> +  }
>> +
>> +  _Thread_State_acquire_critical( the_thread, &lock_context );
>> +
>> +  *clock_id = the_thread->Object.id;
>> +
>> +  _Thread_State_release( the_thread, &lock_context );
>> +
>> +  return 0;
>>  }
>> --
>> 1.8.3.1
>>
>> _______________________________________________
>> devel mailing list
>> devel at rtems.org
>> http://lists.rtems.org/mailman/listinfo/devel
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list