source: rtems/cpukit/itron/src/del_tsk.c @ ba3e987e

4.104.115
Last change on this file since ba3e987e was 345fc11, checked in by Joel Sherrill <joel.sherrill@…>, on 05/22/08 at 20:38:03

2008-05-22 Joel Sherrill <joel.sherrill@…>

  • itron/include/rtems/itron/task.h, itron/src/del_tsk.c, itron/src/exd_tsk.c, itron/src/task.c, posix/include/rtems/posix/threadsup.h, posix/src/cancel.c, posix/src/cancelrun.c, posix/src/pthread.c, posix/src/pthreadexit.c, posix/src/setcancelstate.c, posix/src/setcanceltype.c, posix/src/testcancel.c, rtems/src/taskdelete.c, score/inline/rtems/score/object.inl, score/src/objectclose.c, score/src/threadclose.c: Make all task delete/exit/cancel routines follow the same critical section pattern. Also ensure that POSIX cancelation routines are run at thread exit.
  • Property mode set to 100644
File size: 1.6 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/apimutex.h>
23#include <rtems/score/sysstate.h>
24
25#include <rtems/itron/task.h>
26
27
28/*
29 *  del_tsk - Delete Task
30 */
31
32ER del_tsk(
33  ID tskid
34)
35{
36  register Thread_Control *the_thread;
37  Objects_Locations        location;
38  Objects_Information     *the_information;
39  ER                       result = E_OK; /* to avoid warning */
40
41  _RTEMS_Lock_allocator();
42  the_thread = _ITRON_Task_Get( tskid, &location );
43  switch ( location ) {
44#if defined(RTEMS_MULTIPROCESSING)
45    case OBJECTS_REMOTE:
46#endif
47    case OBJECTS_ERROR:
48      _RTEMS_Unlock_allocator();
49      return _ITRON_Task_Clarify_get_id_error( tskid );
50
51    case OBJECTS_LOCAL:
52
53      if ( _Thread_Is_executing( the_thread ) ) {
54        _RTEMS_Unlock_allocator();
55        _ITRON_return_errorno( E_OBJ );
56      }
57
58      if ( !_States_Is_dormant( the_thread->current_state ) ) {
59        _RTEMS_Unlock_allocator();
60        _ITRON_return_errorno( E_OBJ );
61      }
62
63      the_information = _Objects_Get_information_id( the_thread->Object.id );
64      _Thread_Close( the_information, the_thread );
65
66      _ITRON_Task_Free( the_thread );
67
68      _RTEMS_Unlock_allocator();
69      result = E_OK;
70      break;
71  }
72
73  _ITRON_return_errorno( result );
74}
Note: See TracBrowser for help on using the repository browser.