source: rtems/cpukit/itron/src/cre_tsk.c @ e49f9e6b

4.104.114.84.95
Last change on this file since e49f9e6b was e49f9e6b, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:54:02

2003-09-04 Joel Sherrill <joel@…>

  • include/itron.h, include/itronsys/eventflags.h, include/itronsys/fmempool.h, include/itronsys/intr.h, include/itronsys/mbox.h, include/itronsys/msgbuffer.h, include/itronsys/network.h, include/itronsys/port.h, include/itronsys/semaphore.h, include/itronsys/status.h, include/itronsys/sysmgmt.h, include/itronsys/task.h, include/itronsys/time.h, include/itronsys/types.h, include/itronsys/vmempool.h, include/rtems/itron/config.h, include/rtems/itron/eventflags.h, include/rtems/itron/fmempool.h, include/rtems/itron/intr.h, include/rtems/itron/itronapi.h, include/rtems/itron/mbox.h, include/rtems/itron/msgbuffer.h, include/rtems/itron/network.h, include/rtems/itron/object.h, include/rtems/itron/port.h, include/rtems/itron/semaphore.h, include/rtems/itron/sysmgmt.h, include/rtems/itron/task.h, include/rtems/itron/time.h, include/rtems/itron/vmempool.h, inline/rtems/itron/eventflags.inl, inline/rtems/itron/fmempool.inl, inline/rtems/itron/intr.inl, inline/rtems/itron/mbox.inl, inline/rtems/itron/msgbuffer.inl, inline/rtems/itron/network.inl, inline/rtems/itron/port.inl, inline/rtems/itron/semaphore.inl, inline/rtems/itron/sysmgmt.inl, inline/rtems/itron/task.inl, inline/rtems/itron/time.inl, inline/rtems/itron/vmempool.inl, macros/rtems/itron/eventflags.inl, macros/rtems/itron/fmempool.inl, macros/rtems/itron/intr.inl, macros/rtems/itron/mbox.inl, macros/rtems/itron/msgbuffer.inl, macros/rtems/itron/network.inl, macros/rtems/itron/port.inl, macros/rtems/itron/semaphore.inl, macros/rtems/itron/sysmgmt.inl, macros/rtems/itron/task.inl, macros/rtems/itron/time.inl, macros/rtems/itron/vmempool.inl, src/can_wup.c, src/chg_pri.c, src/cre_mbf.c, src/cre_mbx.c, src/cre_sem.c, src/cre_tsk.c, src/del_mbf.c, src/del_mbx.c, src/del_sem.c, src/del_tsk.c, src/dis_dsp.c, src/ena_dsp.c, src/eventflags.c, src/exd_tsk.c, src/ext_tsk.c, src/fmempool.c, src/frsm_tsk.c, src/get_tid.c, src/itronintr.c, src/itronsem.c, src/itrontime.c, src/mbox.c, src/mboxtranslatereturncode.c, src/msgbuffer.c, src/msgbuffertranslatereturncode.c, src/network.c, src/port.c, src/prcv_mbf.c, src/prcv_mbx.c, src/preq_sem.c, src/psnd_mbf.c, src/rcv_mbf.c, src/rcv_mbx.c, src/ref_mbf.c, src/ref_mbx.c, src/ref_sem.c, src/ref_tsk.c, src/rel_wai.c, src/rot_rdq.c, src/rsm_tsk.c, src/sig_sem.c, src/slp_tsk.c, src/snd_mbf.c, src/snd_mbx.c, src/sta_tsk.c, src/sus_tsk.c, src/sysmgmt.c, src/task.c, src/ter_tsk.c, src/trcv_mbf.c, src/trcv_mbx.c, src/tslp_tsk.c, src/tsnd_mbf.c, src/twai_sem.c, src/vmempool.c, src/wai_sem.c, src/wup_tsk.c: URL for license changed.
  • 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 <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}
121
122
123
124
Note: See TracBrowser for help on using the repository browser.