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

5
Last change on this file since d7665823 was d7665823, checked in by Sebastian Huber <sebastian.huber@…>, on 06/24/15 at 13:43:19

score: Introduce Thread_queue_Heads

Move the storage for the thread queue heads to the threads. Each thread
provides a set of thread queue heads allocated from a dedicated memory
pool. In case a thread blocks on a queue, then it lends its heads to
the queue. In case the thread unblocks, then it takes a free set of
threads from the queue. Since a thread can block on at most one queue
this works. This mechanism is used in FreeBSD. The motivation for this
change is to reduce the memory demands of the synchronization objects.
On a 32-bit uni-processor configuration the Thread_queue_Control size is
now 8 bytes, compared to 64 bytes in RTEMS 4.10 (other changes reduced
the size as well).

  • Property mode set to 100644
File size: 1.7 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  Objects_Locations  location;
32  bool               previous_life_protection;
33
34  previous_life_protection = _Thread_Set_life_protection( true );
35  the_thread = _Thread_Get( id, &location );
36  switch ( location ) {
37
38    case OBJECTS_LOCAL:
39      #if defined(RTEMS_MULTIPROCESSING)
40        if ( the_thread->is_global ) {
41          _Objects_MP_Close(
42            &_RTEMS_tasks_Information.Objects,
43            the_thread->Object.id
44          );
45          _RTEMS_tasks_MP_Send_process_packet(
46            RTEMS_TASKS_MP_ANNOUNCE_DELETE,
47            the_thread->Object.id,
48            0                                /* Not used */
49          );
50        }
51      #endif
52
53      _Thread_Close( the_thread, _Thread_Executing );
54
55      _Objects_Put( &the_thread->Object );
56      _Thread_Set_life_protection( previous_life_protection );
57      return RTEMS_SUCCESSFUL;
58
59#if defined(RTEMS_MULTIPROCESSING)
60    case OBJECTS_REMOTE:
61      _Thread_Dispatch();
62      _Thread_Set_life_protection( previous_life_protection );
63      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
64#endif
65
66    case OBJECTS_ERROR:
67      break;
68  }
69
70  _Thread_Set_life_protection( previous_life_protection );
71
72  return RTEMS_INVALID_ID;
73}
Note: See TracBrowser for help on using the repository browser.