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

4.104.115
Last change on this file since a6608123 was a6608123, checked in by Joel Sherrill <joel.sherrill@…>, on 12/14/08 at 18:31:43

2008-12-14 Joel Sherrill <joel.sherrill@…>

  • itron/src/chg_pri.c, itron/src/cre_tsk.c, itron/src/rot_rdq.c, posix/Makefile.am, posix/include/rtems/posix/mutex.h, posix/include/rtems/posix/priority.h, posix/src/mutex.c, score/include/rtems/score/priority.h: Run all tests successfully with maxixum number of priorities as 16 instead of 256. This was done by temporarily modifying the score priority.h maximum. This allowed testing of all API code to ensure that it worked properly with a reduced number of priorities. Most modifications were to switch from hard-coded maximum to using the SuperCore? variable based upon configured number.
  • posix/src/mutexdefaultattributes.c: Removed.
  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2008.
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#include <rtems/score/apimutex.h>
24
25#include <rtems/itron/task.h>
26
27
28/*
29 *  cre_tsk - Create Task
30 */
31
32ER cre_tsk(
33  ID      tskid,
34  T_CTSK *pk_ctsk
35)
36{
37  register Thread_Control     *the_thread;
38  bool                         status;
39  Priority_Control             core_priority;
40  Objects_Name                 name;
41
42  /*
43   * Validate Parameters.
44   */
45
46 if ( pk_ctsk == NULL )
47    return E_PAR;
48
49  if ((pk_ctsk->tskatr != TA_ASM ) &&
50      (pk_ctsk->tskatr != TA_HLNG) &&
51      (pk_ctsk->tskatr != TA_COP0) &&
52      (pk_ctsk->tskatr != TA_COP1) &&
53      (pk_ctsk->tskatr != TA_COP2) &&
54      (pk_ctsk->tskatr != TA_COP3) &&
55      (pk_ctsk->tskatr != TA_COP4) &&
56      (pk_ctsk->tskatr != TA_COP5) &&
57      (pk_ctsk->tskatr != TA_COP6) &&
58      (pk_ctsk->tskatr != TA_COP7))
59    return E_RSATR;
60
61  if (( pk_ctsk->itskpri <= 0 ) || ( pk_ctsk->itskpri >= PRIORITY_MAXIMUM-1 ))
62    return E_PAR;
63  if ( pk_ctsk->task == NULL )
64    return E_PAR;
65  if ( pk_ctsk->stksz < 0 )
66    return E_PAR;
67
68  /*
69   *  Lock the allocator mutex for protection
70   */
71  _RTEMS_Lock_allocator();
72
73  /*
74   * allocate the thread.
75   */
76
77  the_thread = _ITRON_Task_Allocate( tskid );
78  if ( !the_thread ) {
79    _RTEMS_Unlock_allocator();
80    return _ITRON_Task_Clarify_allocation_id_error( tskid );
81  }
82
83  /*
84   *  Initialize the core thread for this task.
85   */
86
87  name.name_u32 = 0;
88  core_priority = _ITRON_Task_Priority_to_Core( pk_ctsk->itskpri );
89  status = _Thread_Initialize(
90    &_ITRON_Task_Information,
91    the_thread,
92    NULL,
93    pk_ctsk->stksz,
94#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
95    TRUE,          /* XXX - All tasks FP (if the HW supports it) for now */
96#else
97    FALSE,
98#endif
99    core_priority,
100    TRUE,        /* preemptible */
101    THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE,
102    NULL,        /* no budget algorithm callout */
103    0,
104    name
105  );
106
107  if ( !status ) {
108    _ITRON_Task_Free( the_thread );
109    _RTEMS_Unlock_allocator();
110    return E_NOMEM;
111  }
112
113  /*
114   *  This insures we evaluate the process-wide signals pending when we
115   *  first run.
116   *
117   *  NOTE:  Since the thread starts with all unblocked, this is necessary.
118   */
119
120  the_thread->do_post_task_switch_extension = true;
121
122  the_thread->Start.entry_point = (Thread_Entry) pk_ctsk->task;
123
124  _RTEMS_Unlock_allocator();
125  return E_OK;
126}
Note: See TracBrowser for help on using the repository browser.