Changeset 1b67535d in rtems


Ignore:
Timestamp:
Apr 9, 2014, 8:09:57 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
27270b0d
Parents:
b427a92
git-author:
Sebastian Huber <sebastian.huber@…> (04/09/14 08:09:57)
git-committer:
Sebastian Huber <sebastian.huber@…> (04/15/14 07:29:35)
Message:

rtems: Add scheduler get processors

Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/rtems/Makefile.am

    rb427a92 r1b67535d  
    117117endif
    118118librtems_a_SOURCES += src/taskdata.c
     119librtems_a_SOURCES += src/schedulergetprocessorset.c
    119120librtems_a_SOURCES += src/schedulerident.c
    120121
  • cpukit/rtems/include/rtems/rtems/tasks.h

    rb427a92 r1b67535d  
    566566);
    567567
     568#if defined(__RTEMS_HAVE_SYS_CPUSET_H__)
     569/**
     570 * @brief Gets the set of processors owned by the scheduler.
     571 *
     572 * @param[in] scheduler_id Identifier of the scheduler.
     573 * @param[in] cpusetsize Size of the specified processor set buffer in
     574 * bytes.  This value must be positive.
     575 * @param[out] cpuset The processor set owned by the scheduler.  A set bit in
     576 * the processor set means that this processor is owned by the scheduler and a
     577 * cleared bit means the opposite.
     578 *
     579 * @retval RTEMS_SUCCESSFUL Successful operation.
     580 * @retval RTEMS_INVALID_ADDRESS The @a cpuset parameter is @c NULL.
     581 * @retval RTEMS_INVALID_ID Invalid scheduler identifier.
     582 * @retval RTEMS_INVALID_NUMBER The processor set buffer is too small for the
     583 * set of processors owned by the scheduler.
     584 */
     585rtems_status_code rtems_scheduler_get_processor_set(
     586  rtems_id   scheduler_id,
     587  size_t     cpusetsize,
     588  cpu_set_t *cpuset
     589);
     590#endif
     591
    568592/**@}*/
    569593
  • cpukit/score/include/rtems/score/schedulerimpl.h

    rb427a92 r1b67535d  
    462462}
    463463
     464RTEMS_INLINE_ROUTINE bool _Scheduler_Get_by_id(
     465  Objects_Id                id,
     466  const Scheduler_Control **scheduler
     467)
     468{
     469  uint32_t minimum_id = _Scheduler_Build_id( 0 );
     470  uint32_t index = id - minimum_id;
     471
     472  *scheduler = &_Scheduler_Table[ index ];
     473
     474  return index < _Scheduler_Count;
     475}
     476
    464477/** @} */
    465478
  • testsuites/sptests/spscheduler01/init.c

    rb427a92 r1b67535d  
    124124}
    125125
     126static void test_scheduler_get_processors(void)
     127{
     128#if defined(__RTEMS_HAVE_SYS_CPUSET_H__)
     129  rtems_status_code sc;
     130  rtems_name name = BLUE;
     131  rtems_id scheduler_id;
     132  cpu_set_t cpusetone;
     133  cpu_set_t cpuset;
     134  size_t big = 2 * CHAR_BIT * sizeof(cpu_set_t);
     135  size_t cpusetbigsize = CPU_ALLOC_SIZE(big);
     136  cpu_set_t *cpusetbigone;
     137  cpu_set_t *cpusetbig;
     138
     139  CPU_ZERO(&cpusetone);
     140  CPU_SET(0, &cpusetone);
     141
     142  sc = rtems_scheduler_ident(name, &scheduler_id);
     143  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     144
     145  sc = rtems_scheduler_get_processor_set(scheduler_id, sizeof(cpuset), NULL);
     146  rtems_test_assert(sc == RTEMS_INVALID_ADDRESS);
     147
     148  sc = rtems_scheduler_get_processor_set(invalid_id, sizeof(cpuset), &cpuset);
     149  rtems_test_assert(sc == RTEMS_INVALID_ID);
     150
     151  sc = rtems_scheduler_get_processor_set(scheduler_id, 0, &cpuset);
     152  rtems_test_assert(sc == RTEMS_INVALID_NUMBER);
     153
     154  sc = rtems_scheduler_get_processor_set(scheduler_id, sizeof(cpuset), &cpuset);
     155  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     156
     157  rtems_test_assert(CPU_EQUAL(&cpuset, &cpusetone));
     158
     159  cpusetbigone = CPU_ALLOC(big);
     160  rtems_test_assert(cpusetbigone != NULL);
     161
     162  cpusetbig = CPU_ALLOC(big);
     163  rtems_test_assert(cpusetbig != NULL);
     164
     165  CPU_ZERO_S(cpusetbigsize, cpusetbigone);
     166  CPU_SET_S(0, cpusetbigsize, cpusetbigone);
     167
     168  sc = rtems_scheduler_get_processor_set(scheduler_id, cpusetbigsize, cpusetbig);
     169  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     170
     171  rtems_test_assert(CPU_EQUAL_S(cpusetbigsize, cpusetbig, cpusetbigone));
     172
     173  CPU_FREE(cpusetbig);
     174  CPU_FREE(cpusetbigone);
     175#endif /* defined(__RTEMS_HAVE_SYS_CPUSET_H__) */
     176}
     177
    126178static void Init(rtems_task_argument arg)
    127179{
     
    134186  test_task_get_set_affinity();
    135187  test_scheduler_ident();
     188  test_scheduler_get_processors();
    136189
    137190  rtems_test_assert(rtems_resource_snapshot_check(&snapshot));
Note: See TracChangeset for help on using the changeset viewer.