source: rtems/cpukit/rtems/src/taskinitusers.c @ 44e9871

5
Last change on this file since 44e9871 was 44e9871, checked in by Sebastian Huber <sebastian.huber@…>, on 12/22/15 at 08:40:48

score: Avoid dead code in global construction

Update #2514.

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/**
2 * @file
3 *
4 * @brief _RTEMS_tasks_Initialize_user_tasks_body
5 * @ingroup ClassicTasks Tasks
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2008.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/config.h>
23#include <rtems/rtems/status.h>
24#include <rtems/rtems/support.h>
25#include <rtems/rtems/modes.h>
26#include <rtems/rtems/rtemsapi.h>
27#include <rtems/score/assert.h>
28#include <rtems/score/stack.h>
29#include <rtems/rtems/tasksimpl.h>
30#include <rtems/score/thread.h>
31#include <rtems/score/wkspace.h>
32#include <rtems/score/apiext.h>
33
34static void _RTEMS_Global_construction( rtems_task_argument arg )
35{
36  Thread_Entry entry_point = (Thread_Entry)
37    Configuration_RTEMS_API.User_initialization_tasks_table[ 0 ].entry_point;
38
39  (void) arg;
40  _Thread_Global_construction( entry_point );
41}
42
43/*
44 *  _RTEMS_tasks_Initialize_user_tasks_body
45 *
46 *  This routine creates and starts all configured user
47 *  initialization threads.
48 *
49 *  Input parameters: NONE
50 *
51 *  Output parameters:  NONE
52 */
53
54void _RTEMS_tasks_Initialize_user_tasks_body( void )
55{
56  uint32_t                          index;
57  uint32_t                          maximum;
58  rtems_id                          id;
59  rtems_status_code                 return_value;
60  rtems_initialization_tasks_table *user_tasks;
61  bool                              register_global_construction;
62  rtems_task_entry                  entry_point;
63
64  /*
65   *  Move information into local variables
66   */
67  user_tasks = Configuration_RTEMS_API.User_initialization_tasks_table;
68  maximum    = Configuration_RTEMS_API.number_of_initialization_tasks;
69
70  /*
71   *  Verify that we have a set of user tasks to iterate
72   */
73  if ( !user_tasks )
74    return;
75
76  register_global_construction = true;
77
78  /*
79   *  Now iterate over the initialization tasks and create/start them.
80   */
81  for ( index=0 ; index < maximum ; index++ ) {
82    return_value = rtems_task_create(
83      user_tasks[ index ].name,
84      user_tasks[ index ].initial_priority,
85      user_tasks[ index ].stack_size,
86      user_tasks[ index ].mode_set,
87      user_tasks[ index ].attribute_set,
88      &id
89    );
90    if ( !rtems_is_status_successful( return_value ) )
91      _Terminate( INTERNAL_ERROR_RTEMS_API, true, return_value );
92
93    entry_point = user_tasks[ index ].entry_point;
94    if ( entry_point == NULL ) {
95      _Terminate(
96        INTERNAL_ERROR_CORE,
97        false,
98        INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL
99      );
100    }
101
102    if ( register_global_construction ) {
103      register_global_construction = false;
104      entry_point = _RTEMS_Global_construction;
105    }
106
107    return_value = rtems_task_start(
108      id,
109      entry_point,
110      user_tasks[ index ].argument
111    );
112    _Assert( rtems_is_status_successful( return_value ) );
113    (void) return_value;
114  }
115}
Note: See TracBrowser for help on using the repository browser.