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

Last change on this file was d8918c1, checked in by Joel Sherrill <joel.sherrill@…>, on 05/26/14 at 19:01:06

Misc so more scenarios run

  • 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  if ( !schedsim_is_dispatch_allowed() )
67    return;
68
69  current_cpu = Schedsim_Current_cpu;
70  for ( cpu=0 ; cpu < MAX_CPUS ; cpu++ ) {
71    Schedsim_Current_cpu = cpu;
72    check_heir_and_executing();
73    __real__Thread_Dispatch();
74    check_heir_and_executing();
75  }
76
77  Schedsim_Current_cpu = current_cpu;
78}
Note: See TracBrowser for help on using the repository browser.