source: rtems/cpukit/score/src/threadsuspend.c @ 931dd97

4.104.115
Last change on this file since 931dd97 was 931dd97, checked in by Joel Sherrill <joel.sherrill@…>, on 06/01/09 at 21:44:01

2009-06-01 Joel Sherrill <joel.sherrill@…>

  • score/include/rtems/score/thread.h, score/src/threadinitialize.c, score/src/threadreset.c, score/src/threadresume.c, score/src/threadsuspend.c: Nesting count on thread suspension is only supported from ITRON API so disable if ITRON is disabled.
  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 *  Thread Handler
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 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/score/apiext.h>
21#include <rtems/score/context.h>
22#include <rtems/score/interr.h>
23#include <rtems/score/isr.h>
24#include <rtems/score/object.h>
25#include <rtems/score/priority.h>
26#include <rtems/score/states.h>
27#include <rtems/score/sysstate.h>
28#include <rtems/score/thread.h>
29#include <rtems/score/threadq.h>
30#include <rtems/score/userext.h>
31#include <rtems/score/wkspace.h>
32
33/*PAGE
34 *
35 * _Thread_Suspend
36 *
37 * This kernel routine sets the SUSPEND state in the THREAD.  The
38 * THREAD chain and suspend count are adjusted if necessary.
39 *
40 * Input parameters:
41 *   the_thread   - pointer to thread control block
42 *
43 * Output parameters:  NONE
44 *
45 *  INTERRUPT LATENCY:
46 *    ready chain
47 *    select map
48 */
49
50void _Thread_Suspend(
51  Thread_Control   *the_thread
52)
53{
54  ISR_Level      level;
55  Chain_Control *ready;
56
57  ready = the_thread->ready;
58  _ISR_Disable( level );
59  #if defined(RTEMS_ITRON_API)
60    the_thread->suspend_count++;
61  #endif
62  if ( !_States_Is_ready( the_thread->current_state ) ) {
63    the_thread->current_state =
64       _States_Set( STATES_SUSPENDED, the_thread->current_state );
65    _ISR_Enable( level );
66    return;
67  }
68
69  the_thread->current_state = STATES_SUSPENDED;
70
71  if ( _Chain_Has_only_one_node( ready ) ) {
72
73    _Chain_Initialize_empty( ready );
74    _Priority_Remove_from_bit_map( &the_thread->Priority_map );
75
76  } else
77    _Chain_Extract_unprotected( &the_thread->Object.Node );
78
79  _ISR_Flash( level );
80
81  if ( _Thread_Is_heir( the_thread ) )
82     _Thread_Calculate_heir();
83
84  if ( _Thread_Is_executing( the_thread ) )
85    _Context_Switch_necessary = true;
86
87  _ISR_Enable( level );
88}
Note: See TracBrowser for help on using the repository browser.