source: rtems/cpukit/score/src/threadblockingoperationcancel.c @ 5618c37a

4.115
Last change on this file since 5618c37a was 5618c37a, checked in by Sebastian Huber <sebastian.huber@…>, on 07/24/13 at 13:14:48

score: Create thread implementation header

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

Remove superfluous header file includes from various files.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/**
2 * @file
3 *
4 * @brief Cancel a Blocking Operation
5 * @ingroup ScoreThread
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2007.
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/score/threadimpl.h>
22#if defined(RTEMS_DEBUG)
23#include <rtems/score/interr.h>
24#endif
25#include <rtems/score/watchdogimpl.h>
26
27void _Thread_blocking_operation_Cancel(
28#if defined(RTEMS_DEBUG)
29  Thread_blocking_operation_States  sync_state,
30#else
31  Thread_blocking_operation_States  sync_state __attribute__((unused)),
32#endif
33  Thread_Control                   *the_thread,
34  ISR_Level                         level
35)
36{
37  /*
38   *  Cases that should not happen and why.
39   *
40   *  THREAD_BLOCKING_OPERATION_SYNCHRONIZED:
41   *
42   *  This indicates that someone did not enter a blocking
43   *  operation critical section.
44   *
45   *  THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED:
46   *
47   *  This indicates that there was nothing to cancel so
48   *  we should not have been called.
49   */
50
51  #if defined(RTEMS_DEBUG)
52    if ( (sync_state == THREAD_BLOCKING_OPERATION_SYNCHRONIZED) ||
53         (sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED) ) {
54      _Internal_error_Occurred(
55        INTERNAL_ERROR_CORE,
56        true,
57        INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL
58      );
59    }
60  #endif
61
62  /*
63   * The thread is not waiting on anything after this completes.
64   */
65  the_thread->Wait.queue = NULL;
66
67  /*
68   *  If the sync state is timed out, this is very likely not needed.
69   *  But better safe than sorry when it comes to critical sections.
70   */
71  if ( _Watchdog_Is_active( &the_thread->Timer ) ) {
72    _Watchdog_Deactivate( &the_thread->Timer );
73    _ISR_Enable( level );
74    (void) _Watchdog_Remove( &the_thread->Timer );
75  } else
76    _ISR_Enable( level );
77
78  /*
79   *  Global objects with thread queue's should not be operated on from an
80   *  ISR.  But the sync code still must allow short timeouts to be processed
81   *  correctly.
82   */
83
84  _Thread_Unblock( the_thread );
85
86#if defined(RTEMS_MULTIPROCESSING)
87  if ( !_Objects_Is_local_id( the_thread->Object.id ) )
88    _Thread_MP_Free_proxy( the_thread );
89#endif
90
91}
Note: See TracBrowser for help on using the repository browser.