Changeset 0fd6f255 in rtems


Ignore:
Timestamp:
Jul 8, 2016, 2:58:48 PM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
ba5de753
Parents:
3ae199a
git-author:
Sebastian Huber <sebastian.huber@…> (07/08/16 14:58:48)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/25/16 06:40:14)
Message:

score: Relax thread begin extension environment

Update #2752.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/src/threadhandler.c

    r3ae199a r0fd6f255  
    6060
    6161  /*
    62    * Take care that 'begin' extensions get to complete before
    63    * 'switch' extensions can run.  This means must keep dispatch
    64    * disabled until all 'begin' extensions complete.
    65    */
    66   _User_extensions_Thread_begin( executing );
    67 
    68   /*
    6962   * Do not use the level of the thread control block, since it has a
    7063   * different format.
     
    8578   */
    8679  _Thread_Do_dispatch( cpu_self, level );
     80
     81  /*
     82   * Invoke the thread begin extensions in the context of the thread entry
     83   * function with thread dispatching enabled.  This enables use of dynamic
     84   * memory allocation, creation of POSIX keys and use of C++ thread local
     85   * storage.  Blocking synchronization primitives are allowed also.
     86   */
     87  _User_extensions_Thread_begin( executing );
    8788
    8889  /*
  • testsuites/sptests/spextensions01/init.c

    r3ae199a r0fd6f255  
    2626#include <bsp.h>
    2727
     28#include <rtems/score/apimutex.h>
     29#include <rtems/score/sysstate.h>
     30#include <rtems/score/threaddispatch.h>
     31
    2832const char rtems_test_name[] = "SPEXTENSIONS 1";
    2933
     
    3337
    3438static rtems_id master_task;
     39
     40static bool before_multitasking(void)
     41{
     42  return _System_state_Is_before_multitasking(_System_state_Get());
     43}
     44
     45static bool life_protected(void)
     46{
     47  Thread_Control *executing;
     48
     49  executing = _Thread_Get_executing();
     50
     51  return (executing->Life.state & THREAD_LIFE_PROTECTED) != 0;
     52}
     53
     54static void assert_normal_thread_context(void)
     55{
     56  assert(_Thread_Dispatch_is_enabled());
     57  assert(!_RTEMS_Allocator_is_owner());
     58  assert(!life_protected());
     59}
     60
     61static void assert_life_protected_thread_context(void)
     62{
     63  assert(_Thread_Dispatch_is_enabled() || before_multitasking());
     64  assert(!_RTEMS_Allocator_is_owner());
     65  assert(life_protected() || before_multitasking());
     66}
     67
     68static void assert_allocator_protected_thread_context(void)
     69{
     70  assert(_Thread_Dispatch_is_enabled() || before_multitasking());
     71  assert(_RTEMS_Allocator_is_owner());
     72  assert(life_protected() || before_multitasking());
     73}
     74
     75static void assert_thread_dispatch_disabled_context(void)
     76{
     77  assert(!_Thread_Dispatch_is_enabled());
     78  assert(!_RTEMS_Allocator_is_owner());
     79  assert(!life_protected());
     80}
    3581
    3682static void assert_static_order(int index)
     
    55101{
    56102  assert_static_order(0);
     103  assert_allocator_protected_thread_context();
    57104  return true;
    58105}
     
    61108{
    62109  assert_static_order(0);
     110  assert_thread_dispatch_disabled_context();
    63111}
    64112
     
    66114{
    67115  assert_static_order(0);
     116  assert_life_protected_thread_context();
    68117}
    69118
     
    71120{
    72121  assert_static_order(0);
     122  assert_allocator_protected_thread_context();
    73123}
    74124
     
    81131{
    82132  assert_static_order(0);
     133  assert_normal_thread_context();
    83134}
    84135
     
    86137{
    87138  assert_static_order(0);
     139  assert_normal_thread_context();
    88140}
    89141
     
    102154{
    103155  assert_static_order(0);
     156  assert_life_protected_thread_context();
    104157}
    105158
     
    107160{
    108161  assert_static_order(1);
     162  assert_allocator_protected_thread_context();
    109163  return true;
    110164}
     
    113167{
    114168  assert_static_order(1);
     169  assert_thread_dispatch_disabled_context();
    115170}
    116171
     
    118173{
    119174  assert_static_order(1);
     175  assert_life_protected_thread_context();
    120176}
    121177
     
    123179{
    124180  assert_static_order(1);
     181  assert_allocator_protected_thread_context();
    125182}
    126183
     
    133190{
    134191  assert_static_order(1);
     192  assert_normal_thread_context();
    135193}
    136194
     
    138196{
    139197  assert_static_order(1);
     198  assert_normal_thread_context();
    140199}
    141200
     
    154213{
    155214  assert_static_order(1);
     215  assert_life_protected_thread_context();
    156216}
    157217
     
    159219{
    160220  assert_forward_order(2);
     221  assert_allocator_protected_thread_context();
    161222  return true;
    162223}
     
    165226{
    166227  assert_forward_order(2);
     228  assert_thread_dispatch_disabled_context();
    167229}
    168230
     
    170232{
    171233  assert_static_order(2);
     234  assert_life_protected_thread_context();
    172235}
    173236
     
    175238{
    176239  assert_reverse_order(2);
     240  assert_allocator_protected_thread_context();
    177241}
    178242
     
    185249{
    186250  assert_forward_order(2);
     251  assert_normal_thread_context();
    187252}
    188253
     
    190255{
    191256  assert_forward_order(2);
     257  assert_normal_thread_context();
    192258}
    193259
     
    208274{
    209275  assert_forward_order(2);
     276  assert_life_protected_thread_context();
    210277}
    211278
     
    213280{
    214281  assert_forward_order(3);
     282  assert_allocator_protected_thread_context();
    215283  return true;
    216284}
     
    219287{
    220288  assert_forward_order(3);
     289  assert_thread_dispatch_disabled_context();
    221290}
    222291
     
    224293{
    225294  assert_static_order(3);
     295  assert_life_protected_thread_context();
    226296}
    227297
     
    229299{
    230300  assert_reverse_order(3);
     301  assert_allocator_protected_thread_context();
    231302}
    232303
     
    239310{
    240311  assert_forward_order(3);
     312  assert_normal_thread_context();
    241313}
    242314
     
    244316{
    245317  assert_forward_order(3);
     318  assert_normal_thread_context();
    246319}
    247320
     
    260333{
    261334  assert_forward_order(3);
     335  assert_life_protected_thread_context();
    262336}
    263337
Note: See TracChangeset for help on using the changeset viewer.