1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2008. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.com/license/LICENSE. |
---|
8 | * |
---|
9 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | #if HAVE_CONFIG_H |
---|
13 | #include "config.h" |
---|
14 | #endif |
---|
15 | |
---|
16 | #include <rtems/itron.h> |
---|
17 | |
---|
18 | #include <rtems/score/thread.h> |
---|
19 | #include <rtems/score/userext.h> |
---|
20 | #include <rtems/score/wkspace.h> |
---|
21 | #include <rtems/score/apiext.h> |
---|
22 | #include <rtems/score/apimutex.h> |
---|
23 | #include <rtems/score/sysstate.h> |
---|
24 | |
---|
25 | #include <rtems/itron/task.h> |
---|
26 | |
---|
27 | |
---|
28 | /* |
---|
29 | * del_tsk - Delete Task |
---|
30 | */ |
---|
31 | |
---|
32 | ER del_tsk( |
---|
33 | ID tskid |
---|
34 | ) |
---|
35 | { |
---|
36 | register Thread_Control *the_thread; |
---|
37 | Objects_Locations location; |
---|
38 | Objects_Information *the_information; |
---|
39 | ER result = E_OK; /* to avoid warning */ |
---|
40 | |
---|
41 | _RTEMS_Lock_allocator(); |
---|
42 | the_thread = _ITRON_Task_Get( tskid, &location ); |
---|
43 | switch ( location ) { |
---|
44 | #if defined(RTEMS_MULTIPROCESSING) |
---|
45 | case OBJECTS_REMOTE: |
---|
46 | #endif |
---|
47 | case OBJECTS_ERROR: |
---|
48 | _RTEMS_Unlock_allocator(); |
---|
49 | return _ITRON_Task_Clarify_get_id_error( tskid ); |
---|
50 | |
---|
51 | case OBJECTS_LOCAL: |
---|
52 | |
---|
53 | if ( _Thread_Is_executing( the_thread ) ) { |
---|
54 | _RTEMS_Unlock_allocator(); |
---|
55 | _ITRON_return_errorno( E_OBJ ); |
---|
56 | } |
---|
57 | |
---|
58 | if ( !_States_Is_dormant( the_thread->current_state ) ) { |
---|
59 | _RTEMS_Unlock_allocator(); |
---|
60 | _ITRON_return_errorno( E_OBJ ); |
---|
61 | } |
---|
62 | |
---|
63 | the_information = _Objects_Get_information_id( the_thread->Object.id ); |
---|
64 | _Thread_Close( the_information, the_thread ); |
---|
65 | |
---|
66 | _ITRON_Task_Free( the_thread ); |
---|
67 | |
---|
68 | _RTEMS_Unlock_allocator(); |
---|
69 | result = E_OK; |
---|
70 | break; |
---|
71 | } |
---|
72 | |
---|
73 | _ITRON_return_errorno( result ); |
---|
74 | } |
---|