source: rtems/cpukit/rtems/src/taskdelete.c @ c404828

4.115
Last change on this file since c404828 was c404828, checked in by Sebastian Huber <sebastian.huber@…>, on 07/23/13 at 12:56:00

rtems: Create tasks implementation header

Move implementation specific parts of tasks.h and tasks.inl into new
header file tasksimpl.h. The tasks.h contains now only the application
visible API.

  • Property mode set to 100644
File size: 2.5 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/config.h>
23#include <rtems/rtems/status.h>
24#include <rtems/rtems/support.h>
25#include <rtems/rtems/modes.h>
26#include <rtems/score/object.h>
27#include <rtems/score/stack.h>
28#include <rtems/score/states.h>
29#include <rtems/rtems/tasksimpl.h>
30#include <rtems/score/thread.h>
31#include <rtems/score/threadq.h>
32#include <rtems/score/tod.h>
33#include <rtems/score/wkspace.h>
34#include <rtems/score/apiext.h>
35#include <rtems/score/sysstate.h>
36#include <rtems/score/apimutex.h>
37
38rtems_status_code rtems_task_delete(
39  rtems_id id
40)
41{
42  register Thread_Control *the_thread;
43  Objects_Locations        location;
44  Objects_Information     *the_information;
45
46#if defined( RTEMS_SMP )
47  if ( rtems_configuration_is_smp_enabled() ) {
48    return RTEMS_NOT_IMPLEMENTED;
49  }
50#endif
51
52  _RTEMS_Lock_allocator();
53
54  the_thread = _Thread_Get( id, &location );
55  switch ( location ) {
56
57    case OBJECTS_LOCAL:
58      the_information = _Objects_Get_information_id( the_thread->Object.id );
59
60      #if defined(RTEMS_DEBUG)
61        if ( !the_information ) {
62          _Objects_Put( &the_thread->Object );
63          return RTEMS_INVALID_ID;
64          /* This should never happen if _Thread_Get() works right */
65        }
66      #endif
67
68      #if defined(RTEMS_MULTIPROCESSING)
69        if ( the_thread->is_global ) {
70          _Objects_MP_Close( &_RTEMS_tasks_Information, the_thread->Object.id );
71          _RTEMS_tasks_MP_Send_process_packet(
72            RTEMS_TASKS_MP_ANNOUNCE_DELETE,
73            the_thread->Object.id,
74            0                                /* Not used */
75          );
76        }
77      #endif
78
79      _Thread_Close( the_information, the_thread );
80
81      _RTEMS_tasks_Free( the_thread );
82
83      /* FIXME: Lock order reversal */
84      _RTEMS_Unlock_allocator();
85      _Objects_Put( &the_thread->Object );
86      return RTEMS_SUCCESSFUL;
87
88#if defined(RTEMS_MULTIPROCESSING)
89    case OBJECTS_REMOTE:
90      _RTEMS_Unlock_allocator();
91      _Thread_Dispatch();
92      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
93#endif
94
95    case OBJECTS_ERROR:
96      break;
97  }
98
99  _RTEMS_Unlock_allocator();
100  return RTEMS_INVALID_ID;
101}
Note: See TracBrowser for help on using the repository browser.