OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [kernel/] [v2_0/] [include/] [sched.inl] - Blame information for rev 631

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#ifndef CYGONCE_KERNEL_SCHED_INL
2
#define CYGONCE_KERNEL_SCHED_INL
3
 
4
//==========================================================================
5
//
6
//      sched.inl
7
//
8
//      Scheduler class inlines
9
//
10
//==========================================================================
11
//####ECOSGPLCOPYRIGHTBEGIN####
12
// -------------------------------------------
13
// This file is part of eCos, the Embedded Configurable Operating System.
14
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
15
//
16
// eCos is free software; you can redistribute it and/or modify it under
17
// the terms of the GNU General Public License as published by the Free
18
// Software Foundation; either version 2 or (at your option) any later version.
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
21
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
22
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23
// for more details.
24
//
25
// You should have received a copy of the GNU General Public License along
26
// with eCos; if not, write to the Free Software Foundation, Inc.,
27
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28
//
29
// As a special exception, if other files instantiate templates or use macros
30
// or inline functions from this file, or you compile this file and link it
31
// with other works to produce a work based on this file, this file does not
32
// by itself cause the resulting work to be covered by the GNU General Public
33
// License. However the source code for this file must still be made available
34
// in accordance with section (3) of the GNU General Public License.
35
//
36
// This exception does not invalidate any other reasons why a work based on
37
// this file might be covered by the GNU General Public License.
38
//
39
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
40
// at http://sources.redhat.com/ecos/ecos-license/
41
// -------------------------------------------
42
//####ECOSGPLCOPYRIGHTEND####
43
//==========================================================================
44
//#####DESCRIPTIONBEGIN####
45
//
46
// Author(s):   nickg
47
// Contributors:        nickg
48
// Date:        1997-09-09
49
// Purpose:     Define inlines for scheduler classes
50
// Description: Inline functions for the scheduler classes. These are
51
//              not defined in the header so that we have the option
52
//              of making them non-inline.
53
// Usage:
54
//              #include 
55
//              ...
56
//              #include 
57
//              ...
58
//
59
//####DESCRIPTIONEND####
60
//
61
//==========================================================================
62
 
63
#include 
64
 
65
#include    // we use some thread inlines here
66
 
67
// -------------------------------------------------------------------------
68
// Inlines for Cyg_Scheduler class
69
 
70
inline void Cyg_Scheduler::lock()
71
{
72
    // We do not need to do a read-modify-write sequence here because
73
    // the scheduler lock is strictly nesting. Even if we are interrupted
74
    // partway through the increment, the lock will be returned to the same
75
    // value before we are resumed/rescheduled.
76
 
77
    HAL_REORDER_BARRIER();
78
 
79
    inc_sched_lock();
80
 
81
    HAL_REORDER_BARRIER();
82
 
83
    CYG_INSTRUMENT_SCHED(LOCK,get_sched_lock(),0);
84
};
85
 
86
inline void Cyg_Scheduler::unlock()
87
{
88
    // This is an inline wrapper for the real scheduler unlock function in
89
    // Cyg_Scheduler::unlock_inner().
90
 
91
    // Only do anything if the lock is about to go zero, otherwise we simply
92
    // decrement and return. As with lock() we do not need any special code
93
    // to decrement the lock counter.
94
 
95
    CYG_INSTRUMENT_SCHED(UNLOCK,get_sched_lock(),0);
96
 
97
    HAL_REORDER_BARRIER();
98
 
99
    cyg_ucount32 __lock = get_sched_lock() - 1;
100
 
101
    if( __lock == 0 ) unlock_inner(0);
102
    else set_sched_lock(__lock);
103
 
104
    HAL_REORDER_BARRIER();
105
}
106
 
107
inline void Cyg_Scheduler::reschedule()
108
{
109
    // This function performs the equivalent of calling unlock() and
110
    // lock() is succession. Unlike that pair, however, it does not
111
    // leave a brief window between the calls when the lock is unclaimed
112
    // by the current thread.
113
 
114
    CYG_INSTRUMENT_SCHED(RESCHEDULE,get_sched_lock(),0);
115
 
116
    unlock_inner( get_sched_lock() );
117
}
118
 
119
inline void Cyg_Scheduler:: unlock_reschedule()
120
{
121
    // This function decrements the scheduler lock and also looks for
122
    // a reschedule opportunity. When the lock is being decremented
123
    // from 1 to zero this function is equivalent to unlock. When the
124
    // lock is being decremented to a non-zero value, it is more or less
125
    // equivalent to reschedule() followed by unlock().
126
 
127
    CYG_INSTRUMENT_SCHED(UNLOCK,get_sched_lock(),0);
128
 
129
    unlock_inner( get_sched_lock() - 1 );
130
}
131
 
132
inline void Cyg_Scheduler::unlock_simple()
133
{
134
    // This function decrements the lock, but does not call unlock_inner().
135
    // Therefore does not immediately allow another thread to run:
136
    // merely makes it possible for some other thread to run at some
137
    // indeterminate future time.  This is mainly for use by
138
    // debuggers, it should not normally be used anywhere else.
139
 
140
    CYG_INSTRUMENT_SCHED(UNLOCK,get_sched_lock(),0);
141
 
142
    HAL_REORDER_BARRIER();
143
 
144
    if (get_sched_lock() > 1)
145
        set_sched_lock(get_sched_lock() - 1);
146
    else zero_sched_lock();
147
 
148
    HAL_REORDER_BARRIER();
149
}
150
 
151
 
152
// -------------------------------------------------------------------------
153
// Inlines for Cyg_SchedThread class
154
 
155
inline void Cyg_SchedThread::remove()
156
{
157
    if( queue != NULL )
158
    {
159
        queue->remove((Cyg_Thread *)this);
160
        queue = NULL;
161
    }
162
}
163
 
164
// -------------------------------------------------------------------------
165
 
166
#endif // ifndef CYGONCE_KERNEL_SCHED_INL
167
// EOF sched.inl

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.