source: rtems/cpukit/rtems/src/taskdelete.c @ 270394e

5
Last change on this file since 270394e was 270394e, checked in by Sebastian Huber <sebastian.huber@…>, on 05/12/16 at 12:25:50

score: Avoid superfluous life protection

Disable thread dispatching is enough to prevent deletion of the
executing thread. There is no need for an additional life protection.

Update #2555.
Update #2626.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Delete Task
5 *  @ingroup ClassicTasks
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2014.
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.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/rtems/tasksimpl.h>
22#include <rtems/score/apimutex.h>
23#include <rtems/score/threadimpl.h>
24#include <rtems/config.h>
25
26rtems_status_code rtems_task_delete(
27  rtems_id id
28)
29{
30  Thread_Control    *the_thread;
31  Thread_Control    *executing;
32  Objects_Locations  location;
33
34  the_thread = _Thread_Get( id, &location );
35  switch ( location ) {
36
37    case OBJECTS_LOCAL:
38      #if defined(RTEMS_MULTIPROCESSING)
39        if ( the_thread->is_global ) {
40          _Objects_MP_Close(
41            &_RTEMS_tasks_Information.Objects,
42            the_thread->Object.id
43          );
44          _RTEMS_tasks_MP_Send_process_packet(
45            RTEMS_TASKS_MP_ANNOUNCE_DELETE,
46            the_thread->Object.id,
47            0                                /* Not used */
48          );
49        }
50      #endif
51
52      executing = _Thread_Executing;
53
54      if ( the_thread == executing ) {
55        _Thread_Exit( executing );
56      } else {
57        _Thread_Close( the_thread, executing );
58      }
59
60      _Objects_Put( &the_thread->Object );
61      return RTEMS_SUCCESSFUL;
62
63#if defined(RTEMS_MULTIPROCESSING)
64    case OBJECTS_REMOTE:
65      _Thread_Dispatch();
66      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
67#endif
68
69    case OBJECTS_ERROR:
70      break;
71  }
72
73  return RTEMS_INVALID_ID;
74}
Note: See TracBrowser for help on using the repository browser.