source: rtems/cpukit/posix/src/pthreadgetschedparam.c @ 1d572eba

5
Last change on this file since 1d572eba was 3f3f4248, checked in by Sebastian Huber <sebastian.huber@…>, on 10/17/17 at 07:20:20

posix: Remove POSIX_API_Control::schedparam

Move sporadic server scheduler parameters to
POSIX_API_Control::Sporadic. Remove redundant scheduler priority
parameter.

Update #2514.

  • Property mode set to 100644
File size: 1.7 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  POSIX_API_Control       *api;
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  api = the_thread->API_Extensions[ THREAD_API_POSIX ];
57
58  _Thread_Wait_acquire_critical( the_thread, &queue_context );
59
60  *policy = api->schedpolicy;
61  scheduler = _Thread_Scheduler_get_home( the_thread );
62  _POSIX_Threads_Get_sched_param_sporadic( the_thread, api, scheduler, param );
63  priority = the_thread->Real_priority.priority;
64
65  _Thread_Wait_release( the_thread, &queue_context );
66
67  param->sched_priority = _POSIX_Priority_From_core( scheduler, priority );
68  return 0;
69}
Note: See TracBrowser for help on using the repository browser.