source: rtems/cpukit/rtems/src/taskstart.c @ 1506658c

5
Last change on this file since 1506658c was 1506658c, checked in by Sebastian Huber <sebastian.huber@…>, on 01/08/16 at 11:11:03

score: Simplify _Thread_Start()

  • Property mode set to 100644
File size: 1.9 KB
RevLine 
[4c90eb4]1/**
2 * @file
[c4d69e2]3 *
[4c90eb4]4 * @brief  RTEMS Start Task
5 * @ingroup ClassicTasks Tasks
6 */
7
8/*
[3a638ce]9 *  COPYRIGHT (c) 1989-2014.
[c4d69e2]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
[c499856]14 *  http://www.rtems.org/license/LICENSE.
[c4d69e2]15 */
16
[1095ec1]17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
[5618c37a]21#include <rtems/rtems/tasks.h>
22#include <rtems/score/threadimpl.h>
[c4d69e2]23
[64adc13]24/*
[c4d69e2]25 *  rtems_task_start
26 *
27 *  This directive readies the thread identified by the "id"
28 *  based on its current priorty, to await execution.  A thread
29 *  can be started only from the dormant state.
30 *
31 *  Input parameters:
32 *    id          - thread id
33 *    entry_point - start execution address of thread
34 *    argument    - thread argument
35 *
36 *  Output parameters:
37 *    RTEMS_SUCCESSFUL - if successful
38 *    error code        - if unsuccessful
39 */
40
[9c1c574b]41rtems_status_code rtems_task_start(
[e6f664f]42  rtems_id              id,
43  rtems_task_entry      entry_point,
44  rtems_task_argument   argument
[c4d69e2]45)
46{
[ccd5434]47  Thread_Entry_information entry = {
48    .adaptor = _Thread_Entry_adaptor_numeric,
49    .Kinds = {
50      .Numeric = {
51        .entry = entry_point,
52        .argument = argument
53      }
54    }
55  };
56  Thread_Control    *the_thread;
57  Objects_Locations  location;
58  bool               successfully_started;
[c4d69e2]59
60  if ( entry_point == NULL )
61    return RTEMS_INVALID_ADDRESS;
62
63  the_thread = _Thread_Get( id, &location );
64  switch ( location ) {
65
66    case OBJECTS_LOCAL:
[1506658c]67      successfully_started = _Thread_Start( the_thread, &entry );
[1ccb64e1]68
69      _Objects_Put( &the_thread->Object );
70
71      if ( successfully_started ) {
[c4d69e2]72        return RTEMS_SUCCESSFUL;
[1ccb64e1]73      } else {
74        return RTEMS_INCORRECT_STATE;
[c4d69e2]75      }
[ebe61382]76
77#if defined(RTEMS_MULTIPROCESSING)
78    case OBJECTS_REMOTE:
79      _Thread_Dispatch();
80      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
81#endif
82
83    case OBJECTS_ERROR:
84      break;
[c4d69e2]85  }
86
[ebe61382]87  return RTEMS_INVALID_ID;
[c4d69e2]88}
Note: See TracBrowser for help on using the repository browser.