source: rtems/cpukit/posix/src/pthreadgetschedparam.c @ c09db57

5
Last change on this file since c09db57 was c09db57, checked in by Sebastian Huber <sebastian.huber@…>, on 11/28/16 at 12:28:32

score: Fix thread queue context initialization

Initialize the thread queue context with invalid data in debug
configurations to catch missing set up steps.

  • 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/priorityimpl.h>
29#include <rtems/score/schedulerimpl.h>
30#include <rtems/score/threadimpl.h>
31
32int pthread_getschedparam(
33  pthread_t           thread,
34  int                *policy,
35  struct sched_param *param
36)
37{
38  Thread_Control          *the_thread;
39  Thread_queue_Context     queue_context;
40  POSIX_API_Control       *api;
41  const Scheduler_Control *scheduler;
42  Priority_Control         priority;
43
44  if ( policy == NULL || param == NULL ) {
45    return EINVAL;
46  }
47
48  the_thread = _Thread_Get( thread, &queue_context.Lock_context.Lock_context );
49
50  if ( the_thread == NULL ) {
51    return ESRCH;
52  }
53
54  api = the_thread->API_Extensions[ THREAD_API_POSIX ];
55
56  _Thread_queue_Context_initialize( &queue_context );
57  _Thread_Wait_acquire_critical( the_thread, &queue_context );
58
59  *policy = api->Attributes.schedpolicy;
60  *param  = api->Attributes.schedparam;
61
62  scheduler = _Thread_Scheduler_get_home( the_thread );
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.