source: rtems/cpukit/itron/src/cre_tsk.c @ 7ded4e37

4.104.114.84.95
Last change on this file since 7ded4e37 was 7ded4e37, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/15/04 at 04:00:25

Remove unnecessary white spaces.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-1999.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <rtems/itron.h>
17
18#include <rtems/score/thread.h>
19#include <rtems/score/userext.h>
20#include <rtems/score/wkspace.h>
21#include <rtems/score/apiext.h>
22#include <rtems/score/sysstate.h>
23
24#include <rtems/itron/task.h>
25
26
27/*
28 *  cre_tsk - Create Task
29 */
30
31ER cre_tsk(
32  ID      tskid,
33  T_CTSK *pk_ctsk
34)
35{
36  register Thread_Control     *the_thread;
37  boolean                      status;
38  Priority_Control             core_priority;
39
40  /*
41   * Validate Parameters.
42   */
43
44 if ( pk_ctsk == NULL )
45    return E_PAR;
46
47  if ((pk_ctsk->tskatr != TA_ASM ) &&
48      (pk_ctsk->tskatr != TA_HLNG) &&
49      (pk_ctsk->tskatr != TA_COP0) &&
50      (pk_ctsk->tskatr != TA_COP1) &&
51      (pk_ctsk->tskatr != TA_COP2) &&
52      (pk_ctsk->tskatr != TA_COP3) &&
53      (pk_ctsk->tskatr != TA_COP4) &&
54      (pk_ctsk->tskatr != TA_COP5) &&
55      (pk_ctsk->tskatr != TA_COP6) &&
56      (pk_ctsk->tskatr != TA_COP7))
57    return E_RSATR;
58
59  if (( pk_ctsk->itskpri <= 0 ) || ( pk_ctsk->itskpri >= 256 ))
60    return E_PAR;
61  if ( pk_ctsk->task == NULL )
62    return E_PAR;
63  if ( pk_ctsk->stksz < 0 )
64    return E_PAR;
65
66  /*
67   * Disable dispatching.
68   */
69
70  _Thread_Disable_dispatch();
71
72  /*
73   * allocate the thread.
74   */
75
76  the_thread = _ITRON_Task_Allocate( tskid );
77  if ( !the_thread )
78    _ITRON_return_errorno( _ITRON_Task_Clarify_allocation_id_error( tskid ) );
79
80  /*
81   *  Initialize the core thread for this task.
82   */
83
84  core_priority = _ITRON_Task_Priority_to_Core( pk_ctsk->itskpri );
85  status = _Thread_Initialize(
86    &_ITRON_Task_Information,
87    the_thread,
88    NULL,
89    pk_ctsk->stksz,
90#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
91    TRUE,          /* XXX - All tasks FP (if the HW supports it) for now */
92#else
93    FALSE,
94#endif
95    core_priority,
96    TRUE,        /* preemptible */
97    THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE,
98    NULL,        /* no budget algorithm callout */
99    0,
100    NULL
101  );
102
103  if ( !status ) {
104    _ITRON_Task_Free( the_thread );
105    _ITRON_return_errorno( E_NOMEM );
106  }
107
108  /*
109   *  This insures we evaluate the process-wide signals pending when we
110   *  first run.
111   *
112   *  NOTE:  Since the thread starts with all unblocked, this is necessary.
113   */
114
115  the_thread->do_post_task_switch_extension = TRUE;
116
117  the_thread->Start.entry_point = (Thread_Entry) pk_ctsk->task;
118
119  _ITRON_return_errorno( E_OK );
120}
Note: See TracBrowser for help on using the repository browser.