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

4.104.114.84.95
Last change on this file since f26145b was 1095ec1, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/18/05 at 09:03:45

Include config.h.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 *  RTEMS Task Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/rtems/status.h>
21#include <rtems/rtems/support.h>
22#include <rtems/rtems/modes.h>
23#include <rtems/score/object.h>
24#include <rtems/score/stack.h>
25#include <rtems/score/states.h>
26#include <rtems/rtems/tasks.h>
27#include <rtems/score/thread.h>
28#include <rtems/score/threadq.h>
29#include <rtems/score/tod.h>
30#include <rtems/score/userext.h>
31#include <rtems/score/wkspace.h>
32#include <rtems/score/apiext.h>
33#include <rtems/score/sysstate.h>
34
35/*PAGE
36 *
37 *  rtems_task_delete
38 *
39 *  This directive allows a thread to delete itself or the thread
40 *  identified in the id field.  The executive halts execution
41 *  of the thread and frees the thread control block.
42 *
43 *  Input parameters:
44 *    id - thread id
45 *
46 *  Output parameters:
47 *    nothing           - if id is the requesting thread (always succeeds)
48 *    RTEMS_SUCCESSFUL - if successful and id is
49 *                           not the requesting thread
50 *    error code        - if unsuccessful
51 */
52
53rtems_status_code rtems_task_delete(
54  Objects_Id id
55)
56{
57  register Thread_Control *the_thread;
58  Objects_Locations        location;
59  Objects_Information     *the_information;
60
61  the_thread = _Thread_Get( id, &location );
62  switch ( location ) {
63
64    case OBJECTS_REMOTE:
65#if defined(RTEMS_MULTIPROCESSING)
66      _Thread_Dispatch();
67      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
68#endif
69
70    case OBJECTS_ERROR:
71      return RTEMS_INVALID_ID;
72
73    case OBJECTS_LOCAL:
74      the_information = _Objects_Get_information( the_thread->Object.id );
75
76      if ( !the_information ) {
77        _Thread_Enable_dispatch();
78        return RTEMS_INVALID_ID;
79        /* This should never happen if _Thread_Get() works right */
80      }
81
82      _Thread_Close( the_information, the_thread );
83
84      _RTEMS_tasks_Free( the_thread );
85
86#if defined(RTEMS_MULTIPROCESSING)
87      if ( the_thread->is_global ) {
88
89        _Objects_MP_Close( &_RTEMS_tasks_Information, the_thread->Object.id );
90
91        _RTEMS_tasks_MP_Send_process_packet(
92          RTEMS_TASKS_MP_ANNOUNCE_DELETE,
93          the_thread->Object.id,
94          0                                /* Not used */
95        );
96      }
97#endif
98
99      _Thread_Enable_dispatch();
100      return RTEMS_SUCCESSFUL;
101  }
102
103  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
104}
Note: See TracBrowser for help on using the repository browser.