source: rtems/cpukit/posix/src/pthreadgetschedparam.c @ 0e16fa45

5
Last change on this file since 0e16fa45 was c0d602e, checked in by Sebastian Huber <sebastian.huber@…>, on 11/21/17 at 05:19:25

posix: _POSIX_Threads_Get_sched_param_sporadic()

Remove api parameter to simplify the calling functions.

Update #2514.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/**
2 * @file
3 *
4 * @brief Gets Scheduling Policy and Parameters of Individual Threads
5 * @ingroup POSIXAPI
6 */
7
8/*
9 *  13.5.2 Dynamic Thread Scheduling Parameters Access,
10 *         P1003.1c/Draft 10, p. 124
11 *
12 *  COPYRIGHT (c) 1989-2014.
13 *  On-Line Applications Research Corporation (OAR).
14 *
15 *  The license and distribution terms for this file may be
16 *  found in the file LICENSE in this distribution or at
17 *  http://www.rtems.org/license/LICENSE.
18 */
19
20#if HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24#include <pthread.h>
25#include <errno.h>
26
27#include <rtems/posix/pthreadimpl.h>
28#include <rtems/posix/pthreadattrimpl.h>
29#include <rtems/posix/priorityimpl.h>
30#include <rtems/score/schedulerimpl.h>
31#include <rtems/score/threadimpl.h>
32
33int pthread_getschedparam(
34  pthread_t           thread,
35  int                *policy,
36  struct sched_param *param
37)
38{
39  Thread_Control               *the_thread;
40  Thread_queue_Context          queue_context;
41  Thread_CPU_budget_algorithms  budget_algorithm;
42  const Scheduler_Control      *scheduler;
43  Priority_Control              priority;
44
45  if ( policy == NULL || param == NULL ) {
46    return EINVAL;
47  }
48
49  _Thread_queue_Context_initialize( &queue_context );
50  the_thread = _Thread_Get( thread, &queue_context.Lock_context.Lock_context );
51
52  if ( the_thread == NULL ) {
53    return ESRCH;
54  }
55
56  _Thread_Wait_acquire_critical( the_thread, &queue_context );
57
58  scheduler = _Thread_Scheduler_get_home( the_thread );
59  _POSIX_Threads_Get_sched_param_sporadic( the_thread, scheduler, param );
60  priority = the_thread->Real_priority.priority;
61  budget_algorithm = the_thread->budget_algorithm;
62
63  _Thread_Wait_release( the_thread, &queue_context );
64
65  param->sched_priority = _POSIX_Priority_From_core( scheduler, priority );
66  *policy = _POSIX_Thread_Translate_to_sched_policy( budget_algorithm );
67  return 0;
68}
Note: See TracBrowser for help on using the repository browser.