source: rtems/cpukit/rtems/src/scheduleridentbyprocessorset.c @ 66cb142

Last change on this file since 66cb142 was ecabd384, checked in by Sebastian Huber <sebastian.huber@…>, on Jul 11, 2017 at 7:51:43 AM

rtems: Add rtems_scheduler_ident_by_processor_set

Update #3070.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 * Copyright (c) 2017 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/rtems/tasks.h>
20#include <rtems/score/assert.h>
21#include <rtems/score/schedulerimpl.h>
22
23rtems_status_code rtems_scheduler_ident_by_processor_set(
24  size_t           cpusetsize,
25  const cpu_set_t *cpuset,
26  rtems_id        *id
27)
28{
29  Processor_mask              set;
30  Processor_mask_Copy_status  status;
31  uint32_t                    cpu_index;
32  const Scheduler_Control    *scheduler;
33
34  if ( id == NULL ) {
35    return RTEMS_INVALID_ADDRESS;
36  }
37
38  status = _Processor_mask_From_cpu_set_t( &set, cpusetsize, cpuset );
39  if ( status == PROCESSOR_MASK_COPY_INVALID_SIZE ) {
40    return RTEMS_INVALID_SIZE;
41  }
42
43  _Processor_mask_And( &set, &set, _SMP_Get_online_processors() );
44  cpu_index = _Processor_mask_Find_last_set( &set );
45  if ( cpu_index == 0 ) {
46    return RTEMS_INVALID_NAME;
47  }
48
49  scheduler = _Scheduler_Get_by_CPU( _Per_CPU_Get_by_index( cpu_index - 1) );
50#if defined(RTEMS_SMP)
51  if ( scheduler == NULL ) {
52    return RTEMS_INCORRECT_STATE;
53  }
54#else
55  _Assert( scheduler != NULL );
56#endif
57
58  *id = _Scheduler_Build_id( _Scheduler_Get_index( scheduler ) );
59  return RTEMS_SUCCESSFUL;
60}
Note: See TracBrowser for help on using the repository browser.