source: rtems/cpukit/score/src/threadresume.c @ 08311cc3

4.104.114.84.95
Last change on this file since 08311cc3 was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 17:51:34

Updated copyright notice.

  • Property mode set to 100644
File size: 2.2 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.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15#include <rtems/system.h>
16#include <rtems/score/apiext.h>
17#include <rtems/score/context.h>
18#include <rtems/score/interr.h>
19#include <rtems/score/isr.h>
20#include <rtems/score/object.h>
21#include <rtems/score/priority.h>
22#include <rtems/score/states.h>
23#include <rtems/score/sysstate.h>
24#include <rtems/score/thread.h>
25#include <rtems/score/threadq.h>
26#include <rtems/score/userext.h>
27#include <rtems/score/wkspace.h>
28
29/*PAGE
30 *
31 *  _Thread_Resume
32 *
33 *  This kernel routine clears the SUSPEND state if the suspend_count
34 *  drops below one.  If the force parameter is set the suspend_count
35 *  is forced back to zero. The thread ready chain is adjusted if
36 *  necessary and the Heir thread is set accordingly.
37 *
38 *  Input parameters:
39 *    the_thread - pointer to thread control block
40 *    force      - force the suspend count back to 0
41 *
42 *  Output parameters:  NONE
43 *
44 *  INTERRUPT LATENCY:
45 *    priority map
46 *    select heir
47 */
48
49
50void _Thread_Resume(
51  Thread_Control   *the_thread,
52  boolean           force
53)
54{
55
56  ISR_Level       level;
57  States_Control  current_state;
58
59  _ISR_Disable( level );
60 
61  if ( force == TRUE )
62    the_thread->suspend_count = 0;
63  else
64    the_thread->suspend_count--;
65
66  if ( the_thread->suspend_count > 0 ) {
67    _ISR_Enable( level );
68    return;
69  }
70
71  current_state = the_thread->current_state;
72  if ( current_state & STATES_SUSPENDED ) {
73    current_state =
74    the_thread->current_state = _States_Clear(STATES_SUSPENDED, current_state);
75
76    if ( _States_Is_ready( current_state ) ) {
77
78      _Priority_Add_to_bit_map( &the_thread->Priority_map );
79
80      _Chain_Append_unprotected(the_thread->ready, &the_thread->Object.Node);
81
82      _ISR_Flash( level );
83
84      if ( the_thread->current_priority < _Thread_Heir->current_priority ) {
85        _Thread_Heir = the_thread;
86        if ( _Thread_Executing->is_preemptible ||
87             the_thread->current_priority == 0 )
88          _Context_Switch_necessary = TRUE;
89      }
90    }
91  }
92
93  _ISR_Enable( level );
94}
Note: See TracBrowser for help on using the repository browser.