source: rtems-schedsim/schedsim/shell/shared/wrap_thread_dispatch.c @ e5e757b

Last change on this file since e5e757b was e5e757b, checked in by Joel Sherrill <joel.sherrill@…>, on May 26, 2014 at 6:26:41 PM

_Thread_Dispatch wrapper is now shared between uniprocessor and SMP configurations

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 *  Thread Dispatch Wrapper Implmentation
3 *
4 *  COPYRIGHT (c) 1989-2013.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 */
11
12#include "shell.h"
13#include <schedsim_shell.h>
14
15#include <stdlib.h>
16#include <stdio.h>
17#include <rtems.h>
18
19typedef Thread_Control * Thread_Control_ptr;
20uint32_t Schedsim_Current_cpu = 0;
21
22Thread_Control_ptr *last_heir = NULL;
23Thread_Control_ptr *last_executing = NULL;
24
25extern void __real__Thread_Dispatch(void);
26
27#if RTEMS_SMP
28  #define MAX_CPUS _SMP_Processor_count
29#else
30  #define MAX_CPUS 1
31#endif
32
33void Init__wrap__Thread_Dispatch()
34{
35  last_heir = (Thread_Control_ptr *) calloc(
36    sizeof( Thread_Control_ptr ),
37    MAX_CPUS
38  );
39  last_executing =  (Thread_Control_ptr *) calloc(
40    sizeof( Thread_Control_ptr ),
41    MAX_CPUS
42  );
43}
44
45void check_heir_and_executing(void)
46{
47  uint32_t level;
48
49  _ISR_Disable_without_giant( level );
50    if ( last_heir[Schedsim_Current_cpu] != _Thread_Heir )
51      PRINT_HEIR();
52
53    if ( last_executing[Schedsim_Current_cpu] != _Thread_Executing )
54      PRINT_EXECUTING();
55
56    last_heir[Schedsim_Current_cpu] = _Thread_Heir;
57    last_executing[Schedsim_Current_cpu] = _Thread_Executing;
58  _ISR_Enable_without_giant( level );
59}
60
61void __wrap__Thread_Dispatch(void)
62{
63  uint32_t   cpu;
64  uint32_t   current_cpu;
65
66  current_cpu = Schedsim_Current_cpu;
67  for ( cpu=0 ; cpu < MAX_CPUS ; cpu++ ) {
68    Schedsim_Current_cpu = cpu;
69    check_heir_and_executing();
70    __real__Thread_Dispatch();
71    check_heir_and_executing();
72  }
73
74  Schedsim_Current_cpu = current_cpu;
75}
Note: See TracBrowser for help on using the repository browser.