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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [kernel/] [current/] [include/] [sched.inl] - Blame information for rev 851

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

Line No. Rev Author Line
1 786 skrzyp
#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 Free Software Foundation, 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
19
// version.
20
//
21
// eCos is distributed in the hope that it will be useful, but WITHOUT
22
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
24
// for more details.
25
//
26
// You should have received a copy of the GNU General Public License
27
// along with eCos; if not, write to the Free Software Foundation, Inc.,
28
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
29
//
30
// As a special exception, if other files instantiate templates or use
31
// macros or inline functions from this file, or you compile this file
32
// and link it with other works to produce a work based on this file,
33
// this file does not by itself cause the resulting work to be covered by
34
// the GNU General Public License. However the source code for this file
35
// must still be made available in accordance with section (3) of the GNU
36
// General Public License v2.
37
//
38
// This exception does not invalidate any other reasons why a work based
39
// on this file might be covered by the GNU General Public License.
40
// -------------------------------------------
41
// ####ECOSGPLCOPYRIGHTEND####
42
//==========================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):   nickg
46
// Contributors:        nickg
47
// Date:        1997-09-09
48
// Purpose:     Define inlines for scheduler classes
49
// Description: Inline functions for the scheduler classes. These are
50
//              not defined in the header so that we have the option
51
//              of making them non-inline.
52
// Usage:
53
//              #include 
54
//              ...
55
//              #include 
56
//              ...
57
//
58
//####DESCRIPTIONEND####
59
//
60
//==========================================================================
61
 
62
#include 
63
#include 
64
 
65
// -------------------------------------------------------------------------
66
// Inlines for Cyg_Scheduler class
67
 
68
inline void Cyg_Scheduler::lock()
69
{
70
    // We do not need to do a read-modify-write sequence here because
71
    // the scheduler lock is strictly nesting. Even if we are interrupted
72
    // partway through the increment, the lock will be returned to the same
73
    // value before we are resumed/rescheduled.
74
 
75
    HAL_REORDER_BARRIER();
76
 
77
    inc_sched_lock();
78
 
79
    HAL_REORDER_BARRIER();
80
 
81
    CYG_INSTRUMENT_SCHED(LOCK,get_sched_lock(),0);
82
};
83
 
84
inline void Cyg_Scheduler::unlock()
85
{
86
    // This is an inline wrapper for the real scheduler unlock function in
87
    // Cyg_Scheduler::unlock_inner().
88
 
89
    // Only do anything if the lock is about to go zero, otherwise we simply
90
    // decrement and return. As with lock() we do not need any special code
91
    // to decrement the lock counter.
92
 
93
    CYG_INSTRUMENT_SCHED(UNLOCK,get_sched_lock(),0);
94
 
95
    HAL_REORDER_BARRIER();
96
 
97
    cyg_ucount32 __lock = get_sched_lock() - 1;
98
 
99
    if( __lock == 0 ) unlock_inner(0);
100
    else set_sched_lock(__lock);
101
 
102
    HAL_REORDER_BARRIER();
103
}
104
 
105
inline void Cyg_Scheduler::reschedule()
106
{
107
    // This function performs the equivalent of calling unlock() and
108
    // lock() is succession. Unlike that pair, however, it does not
109
    // leave a brief window between the calls when the lock is unclaimed
110
    // by the current thread.
111
 
112
    CYG_INSTRUMENT_SCHED(RESCHEDULE,get_sched_lock(),0);
113
 
114
    unlock_inner( get_sched_lock() );
115
}
116
 
117
inline void Cyg_Scheduler:: unlock_reschedule()
118
{
119
    // This function decrements the scheduler lock and also looks for
120
    // a reschedule opportunity. When the lock is being decremented
121
    // from 1 to zero this function is equivalent to unlock. When the
122
    // lock is being decremented to a non-zero value, it is more or less
123
    // equivalent to reschedule() followed by unlock().
124
 
125
    CYG_INSTRUMENT_SCHED(UNLOCK,get_sched_lock(),0);
126
 
127
    unlock_inner( get_sched_lock() - 1 );
128
}
129
 
130
inline void Cyg_Scheduler::unlock_simple()
131
{
132
    // This function decrements the lock, but does not call unlock_inner().
133
    // Therefore does not immediately allow another thread to run:
134
    // merely makes it possible for some other thread to run at some
135
    // indeterminate future time.  This is mainly for use by
136
    // debuggers, it should not normally be used anywhere else.
137
 
138
    CYG_INSTRUMENT_SCHED(UNLOCK,get_sched_lock(),0);
139
 
140
    HAL_REORDER_BARRIER();
141
 
142
    if (get_sched_lock() > 1)
143
        set_sched_lock(get_sched_lock() - 1);
144
    else zero_sched_lock();
145
 
146
    HAL_REORDER_BARRIER();
147
}
148
 
149
 
150
// -------------------------------------------------------------------------
151
// Inlines for Cyg_SchedThread class
152
 
153
#include    // we use some thread inlines here
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.