source: rtems/testsuites/smptests/smp02/tasks.c @ 03c9f24

5
Last change on this file since 03c9f24 was 03c9f24, checked in by Sebastian Huber <sebastian.huber@…>, on 04/05/19 at 06:03:12

rtems: Add rtems_scheduler_get_processor()

Add rtems_scheduler_get_processor() as a replacement for
rtems_get_current_processor(). The rtems_get_current_processor() is a
bit orphaned. Adopt it by the Scheduler Manager. This is in line with
the glibc sched_getcpu() function.

Deprecate rtems_get_current_processor().

Update #3731.

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2011.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include "system.h"
15
16static void LogSemaphore(
17  bool      obtained,
18  uint32_t  cpu_num,
19  uint32_t  task_index
20){
21  if (Log_index < LOG_SIZE) {
22    /* Log the information */
23    Log[ Log_index ].IsLocked   = obtained;
24    Log[ Log_index ].cpu_num    = cpu_num;
25    Log[ Log_index ].task_index = task_index;
26    Log_index++;
27  }
28}
29
30rtems_task Test_task(
31  rtems_task_argument task_index
32)
33{
34  uint32_t          cpu_num;
35  rtems_status_code sc;
36
37  cpu_num = rtems_scheduler_get_processor();
38
39  do {
40
41    /* Poll to obtain the synchronization semaphore */
42    do {
43      sc = rtems_semaphore_obtain( Semaphore, RTEMS_NO_WAIT, 0 );
44    } while (sc != RTEMS_SUCCESSFUL );
45
46    LogSemaphore(true, cpu_num, task_index);
47    LogSemaphore(false, cpu_num, task_index);
48 
49    rtems_semaphore_release( Semaphore );
50  } while(1);
51}
Note: See TracBrowser for help on using the repository browser.