Changeset 7147dc4 in rtems


Ignore:
Timestamp:
Nov 8, 2017, 1:37:35 PM (17 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
64ba1a96
Parents:
8d0a0aa
git-author:
Sebastian Huber <sebastian.huber@…> (11/08/17 13:37:35)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/09/17 07:12:11)
Message:

posix: Remove POSIX_API_Control::schedpolicy

Use the thread CPU budget algorithm to determine the scheduler policy.
This fixes also pthread_getschedparam() for Classic tasks.

Update #2514.

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/include/rtems/posix/pthreadimpl.h

    r8d0a0aa r7147dc4  
    7878);
    7979
     80int _POSIX_Thread_Translate_to_sched_policy(
     81  Thread_CPU_budget_algorithms budget_algorithm
     82);
     83
    8084/**
    8185 * @brief Translate sched_param into SuperCore terms.
  • cpukit/posix/include/rtems/posix/threadsup.h

    r8d0a0aa r7147dc4  
    4343  /** Created with explicit or inherited scheduler. */
    4444  bool created_with_explicit_scheduler;
    45 
    46   /** The scheduler policy. */
    47   int schedpolicy;
    4845
    4946  /**
  • cpukit/posix/src/psxtransschedparam.c

    r8d0a0aa r7147dc4  
    2323
    2424#include <rtems/posix/pthreadimpl.h>
     25
     26int _POSIX_Thread_Translate_to_sched_policy(
     27  Thread_CPU_budget_algorithms budget_algorithm
     28)
     29{
     30  switch ( budget_algorithm ) {
     31    case THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE:
     32      return SCHED_OTHER;
     33    case THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE:
     34      return SCHED_RR;
     35    case THREAD_CPU_BUDGET_ALGORITHM_CALLOUT:
     36      return SCHED_SPORADIC;
     37    default:
     38      _Assert( budget_algorithm == THREAD_CPU_BUDGET_ALGORITHM_NONE );
     39      return SCHED_FIFO;
     40  }
     41}
    2542
    2643int _POSIX_Thread_Translate_sched_param(
  • cpukit/posix/src/pthread.c

    r8d0a0aa r7147dc4  
    142142
    143143  _Thread_State_acquire( executing, &lock_context );
    144 
    145   if ( api->schedpolicy == SCHED_SPORADIC ) {
    146     _Watchdog_Per_CPU_remove_monotonic( &api->Sporadic.Timer );
    147   }
    148 
     144  _Watchdog_Per_CPU_remove_monotonic( &api->Sporadic.Timer );
    149145  _Thread_State_release( executing, &lock_context );
    150146}
  • cpukit/posix/src/pthreadcreate.c

    r8d0a0aa r7147dc4  
    253253  api->created_with_explicit_scheduler =
    254254    ( the_attr->inheritsched == PTHREAD_EXPLICIT_SCHED );
    255   api->schedpolicy = the_attr->schedpolicy;
    256255
    257256  _Priority_Node_set_priority( &api->Sporadic.Low_priority, core_low_prio );
  • cpukit/posix/src/pthreadgetattrnp.c

    r8d0a0aa r7147dc4  
    3535)
    3636{
    37   Thread_Control          *the_thread;
    38   ISR_lock_Context         lock_context;
    39   POSIX_API_Control       *api;
    40   const Scheduler_Control *scheduler;
    41   bool                     ok;
     37  Thread_Control               *the_thread;
     38  ISR_lock_Context              lock_context;
     39  const POSIX_API_Control      *api;
     40  Thread_CPU_budget_algorithms  budget_algorithm;
     41  const Scheduler_Control      *scheduler;
     42  bool                          ok;
    4243
    4344  if ( attr == NULL ) {
     
    5758  api = the_thread->API_Extensions[ THREAD_API_POSIX ];
    5859
    59   attr->is_initialized = true;
    6060  attr->stackaddr = the_thread->Start.Initial_stack.area;
    6161  attr->stacksize = the_thread->Start.Initial_stack.size;
    62   attr->contentionscope = PTHREAD_SCOPE_PROCESS;
    6362
    6463  if ( api->created_with_explicit_scheduler ) {
     
    6766    attr->inheritsched = PTHREAD_INHERIT_SCHED;
    6867  }
    69 
    70   attr->schedpolicy = api->schedpolicy;
    7168
    7269  scheduler = _Thread_Scheduler_get_home( the_thread );
     
    8178    &attr->schedparam
    8279  );
    83   attr->cputime_clock_allowed = 1;
    8480
    8581  if ( _Thread_Is_joinable( the_thread ) ) {
     
    9793  );
    9894
     95  budget_algorithm = the_thread->budget_algorithm;
     96
    9997  _Thread_State_release( the_thread, &lock_context );
     98
     99  attr->is_initialized = true;
     100  attr->contentionscope = PTHREAD_SCOPE_PROCESS;
     101  attr->cputime_clock_allowed = 1;
     102  attr->schedpolicy =
     103    _POSIX_Thread_Translate_to_sched_policy( budget_algorithm );
     104
    100105  return ok ? 0 : EINVAL;
    101106}
  • cpukit/posix/src/pthreadgetschedparam.c

    r8d0a0aa r7147dc4  
    3737)
    3838{
    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;
     39  Thread_Control               *the_thread;
     40  Thread_queue_Context          queue_context;
     41  const POSIX_API_Control      *api;
     42  Thread_CPU_budget_algorithms  budget_algorithm;
     43  const Scheduler_Control      *scheduler;
     44  Priority_Control              priority;
    4445
    4546  if ( policy == NULL || param == NULL ) {
     
    5859  _Thread_Wait_acquire_critical( the_thread, &queue_context );
    5960
    60   *policy = api->schedpolicy;
    6161  scheduler = _Thread_Scheduler_get_home( the_thread );
    6262  _POSIX_Threads_Get_sched_param_sporadic( the_thread, api, scheduler, param );
    6363  priority = the_thread->Real_priority.priority;
     64  budget_algorithm = the_thread->budget_algorithm;
    6465
    6566  _Thread_Wait_release( the_thread, &queue_context );
    6667
    6768  param->sched_priority = _POSIX_Priority_From_core( scheduler, priority );
     69  *policy = _POSIX_Thread_Translate_to_sched_policy( budget_algorithm );
    6870  return 0;
    6971}
  • cpukit/posix/src/pthreadsetschedparam.c

    r8d0a0aa r7147dc4  
    9595  }
    9696
    97   api->schedpolicy = policy;
    98 
    9997  the_thread->budget_algorithm = budget_algorithm;
    10098  the_thread->budget_callout   = budget_callout;
  • testsuites/psxtests/psxclassic01/init.c

    r8d0a0aa r7147dc4  
    2525#include <unistd.h>
    2626#include <errno.h>
     27#include <string.h>
     28#include <sched.h>
    2729
    2830const char rtems_test_name[] = "PSXCLASSIC 1";
    2931
    30 int       Caught_signo = -1;
    31 siginfo_t Caught_siginfo = { -1, -1, };
     32static int       Caught_signo = -1;
     33static siginfo_t Caught_siginfo = { -1, -1, };
    3234
    33 /* forward declarations to avoid warnings */
    34 rtems_task Init(rtems_task_argument arg);
    35 void handler(int signo);
    36 void handler_info(int signo, siginfo_t *info, void *context);
    37 rtems_task test_task(rtems_task_argument arg);
    38 
    39 void handler(int signo)
     35static void handler(int signo)
    4036{
    4137  Caught_signo = signo;
    4238}
    4339
    44 void handler_info(int signo, siginfo_t *info, void *context)
     40static void handler_info(int signo, siginfo_t *info, void *context)
    4541{
    4642  Caught_signo = signo;
     
    4844}
    4945
    50 rtems_task test_task(rtems_task_argument arg)
     46static rtems_task test_task(rtems_task_argument arg)
    5147{
    5248  int sc;
     
    5854  printf("test_task starting...\n");
    5955
     56  policy = -1;
     57  memset( &param, -1, sizeof( param ) );
    6058  sc = pthread_getschedparam( pthread_self(), &policy, &param );
    6159  rtems_test_assert( sc == 0 );
     60  rtems_test_assert( policy == SCHED_FIFO );
     61  rtems_test_assert(
     62    param.sched_priority == sched_get_priority_max( SCHED_FIFO )
     63  );
    6264
    6365  sc = pthread_setschedparam( pthread_self(), policy, &param );
     
    133135}
    134136
    135 rtems_task Init( rtems_task_argument arg )
     137static rtems_task Init( rtems_task_argument arg )
    136138{
    137139  rtems_id  task_id;
Note: See TracChangeset for help on using the changeset viewer.