source: rtems/cpukit/rtems/src/taskdelete.c @ 3d7eecc0

4.115
Last change on this file since 3d7eecc0 was 3d7eecc0, checked in by Sebastian Huber <sebastian.huber@…>, on 05/21/13 at 15:06:21

smp: Replace task delete with suspend

The rtems_task_delete() does not work on SMP at the moment. See PR1814.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Delete Task
5 *  @ingroup ClassicTasks
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2008.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/rtems/status.h>
23#include <rtems/rtems/support.h>
24#include <rtems/rtems/modes.h>
25#include <rtems/score/object.h>
26#include <rtems/score/stack.h>
27#include <rtems/score/states.h>
28#include <rtems/rtems/tasks.h>
29#include <rtems/score/thread.h>
30#include <rtems/score/threadq.h>
31#include <rtems/score/tod.h>
32#include <rtems/score/wkspace.h>
33#include <rtems/score/apiext.h>
34#include <rtems/score/sysstate.h>
35#include <rtems/score/apimutex.h>
36
37rtems_status_code rtems_task_delete(
38  rtems_id id
39)
40{
41#ifdef RTEMS_SMP
42  return rtems_task_suspend( id );
43#else /* RTEMS_SMP */
44  register Thread_Control *the_thread;
45  Objects_Locations        location;
46  Objects_Information     *the_information;
47
48  _RTEMS_Lock_allocator();
49
50  the_thread = _Thread_Get( id, &location );
51  switch ( location ) {
52
53    case OBJECTS_LOCAL:
54      the_information = _Objects_Get_information_id( the_thread->Object.id );
55
56      #if defined(RTEMS_DEBUG)
57        if ( !the_information ) {
58          _Thread_Enable_dispatch();
59          return RTEMS_INVALID_ID;
60          /* This should never happen if _Thread_Get() works right */
61        }
62      #endif
63
64      #if defined(RTEMS_MULTIPROCESSING)
65        if ( the_thread->is_global ) {
66          _Objects_MP_Close( &_RTEMS_tasks_Information, the_thread->Object.id );
67          _RTEMS_tasks_MP_Send_process_packet(
68            RTEMS_TASKS_MP_ANNOUNCE_DELETE,
69            the_thread->Object.id,
70            0                                /* Not used */
71          );
72        }
73      #endif
74
75      _Thread_Close( the_information, the_thread );
76
77      _RTEMS_tasks_Free( the_thread );
78
79      _RTEMS_Unlock_allocator();
80      _Thread_Enable_dispatch();
81      return RTEMS_SUCCESSFUL;
82
83#if defined(RTEMS_MULTIPROCESSING)
84    case OBJECTS_REMOTE:
85      _RTEMS_Unlock_allocator();
86      _Thread_Dispatch();
87      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
88#endif
89
90    case OBJECTS_ERROR:
91      break;
92  }
93
94  _RTEMS_Unlock_allocator();
95  return RTEMS_INVALID_ID;
96#endif /* RTEMS_SMP */
97}
Note: See TracBrowser for help on using the repository browser.