source: rtems/cpukit/rtems/src/taskstart.c @ 1095ec1

4.104.114.84.95
Last change on this file since 1095ec1 was 1095ec1, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/18/05 at 09:03:45

Include config.h.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2 *  RTEMS Task Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/rtems/status.h>
21#include <rtems/rtems/support.h>
22#include <rtems/rtems/modes.h>
23#include <rtems/score/object.h>
24#include <rtems/score/stack.h>
25#include <rtems/score/states.h>
26#include <rtems/rtems/tasks.h>
27#include <rtems/score/thread.h>
28#include <rtems/score/threadq.h>
29#include <rtems/score/tod.h>
30#include <rtems/score/userext.h>
31#include <rtems/score/wkspace.h>
32#include <rtems/score/apiext.h>
33#include <rtems/score/sysstate.h>
34
35/*PAGE
36 *
37 *  rtems_task_start
38 *
39 *  This directive readies the thread identified by the "id"
40 *  based on its current priorty, to await execution.  A thread
41 *  can be started only from the dormant state.
42 *
43 *  Input parameters:
44 *    id          - thread id
45 *    entry_point - start execution address of thread
46 *    argument    - thread argument
47 *
48 *  Output parameters:
49 *    RTEMS_SUCCESSFUL - if successful
50 *    error code        - if unsuccessful
51 */
52
53rtems_status_code rtems_task_start(
54  rtems_id              id,
55  rtems_task_entry      entry_point,
56  rtems_task_argument   argument
57)
58{
59  register Thread_Control *the_thread;
60  Objects_Locations        location;
61
62  if ( entry_point == NULL )
63    return RTEMS_INVALID_ADDRESS;
64
65  the_thread = _Thread_Get( id, &location );
66  switch ( location ) {
67
68    case OBJECTS_REMOTE:
69#if defined(RTEMS_MULTIPROCESSING)
70      _Thread_Dispatch();
71      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
72#endif
73
74    case OBJECTS_ERROR:
75      return RTEMS_INVALID_ID;
76
77    case OBJECTS_LOCAL:
78      if ( _Thread_Start(
79             the_thread, THREAD_START_NUMERIC, entry_point, NULL, argument ) ) {
80        _Thread_Enable_dispatch();
81        return RTEMS_SUCCESSFUL;
82      }
83      _Thread_Enable_dispatch();
84      return RTEMS_INCORRECT_STATE;
85  }
86
87  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
88}
Note: See TracBrowser for help on using the repository browser.