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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [kernel/] [current/] [include/] [bitmap.hxx] - Blame information for rev 825

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

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_KERNEL_BITMAP_HXX
2
#define CYGONCE_KERNEL_BITMAP_HXX
3
 
4
//==========================================================================
5
//
6
//      bitmap.hxx
7
//
8
//      Bitmap scheduler class declaration(s)
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, 2006 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-10
48
// Purpose:     Define bitmap scheduler implementation
49
// Description: The classes defined here are used as base classes
50
//              by the common classes that define schedulers and thread
51
//              things.
52
// Usage:       Included according to configuration by
53
//              
54
//
55
//####DESCRIPTIONEND####
56
//
57
//==========================================================================
58
 
59
#include 
60
 
61
// -------------------------------------------------------------------------
62
// The macro CYGNUM_KERNEL_SCHED_BITMAP_SIZE contains the number of bits
63
// that the scheduler bitmap should contain. It is derived from the number
64
// of threads that the system is allowed to use during configuration.
65
 
66
#ifndef CYGNUM_KERNEL_SCHED_BITMAP_SIZE
67
#define CYGNUM_KERNEL_SCHED_BITMAP_SIZE 32
68
#endif
69
 
70
#if CYGNUM_KERNEL_SCHED_BITMAP_SIZE <= 8
71
typedef cyg_ucount8 cyg_sched_bitmap;
72
#elif CYGNUM_KERNEL_SCHED_BITMAP_SIZE <= 16
73
typedef cyg_ucount16 cyg_sched_bitmap;
74
#elif CYGNUM_KERNEL_SCHED_BITMAP_SIZE <= 32
75
typedef cyg_ucount32 cyg_sched_bitmap;
76
#else
77
#error Bitmaps greater than 32 bits not currently allowed
78
#endif
79
 
80
// -------------------------------------------------------------------------
81
// Customize the scheduler
82
 
83
#define CYGIMP_THREAD_PRIORITY  1
84
 
85
#define CYG_THREAD_MIN_PRIORITY (CYGNUM_KERNEL_SCHED_BITMAP_SIZE-1)
86
#define CYG_THREAD_MAX_PRIORITY 0
87
 
88
// set default scheduling info value for thread constructors.
89
#define CYG_SCHED_DEFAULT_INFO  CYG_THREAD_MAX_PRIORITY
90
 
91
// -------------------------------------------------------------------------
92
// This class contains the implementation details of the scheduler, and
93
// provides a standard API for accessing it.
94
 
95
class Cyg_Scheduler_Implementation
96
    : public Cyg_Scheduler_Base
97
{
98
    friend class Cyg_ThreadQueue_Implementation;
99
    friend class Cyg_SchedThread_Implementation;
100
 
101
    cyg_sched_bitmap    run_queue;
102
 
103
    Cyg_Thread          *thread_table[CYGNUM_KERNEL_SCHED_BITMAP_SIZE];
104
 
105
 
106
protected:
107
 
108
    Cyg_Scheduler_Implementation();     // Constructor
109
 
110
    // The following functions provide the scheduler implementation
111
    // interface to the Cyg_Scheduler class. These are protected
112
    // so that only the scheduler can call them.
113
 
114
    // choose a new thread
115
    Cyg_Thread  *schedule();
116
 
117
    // make thread schedulable
118
    void        add_thread(Cyg_Thread *thread);
119
 
120
    // make thread un-schedulable
121
    void        rem_thread(Cyg_Thread *thread);
122
 
123
    // register thread with scheduler
124
    void        register_thread(Cyg_Thread *thread);
125
 
126
    // deregister thread
127
    void        deregister_thread(Cyg_Thread *thread);
128
 
129
    // Test the given priority for uniqueness
130
    cyg_bool    unique( cyg_priority priority);
131
 
132
public:
133
    void set_idle_thread( Cyg_Thread *thread, HAL_SMP_CPU_TYPE cpu );
134
 
135
};
136
 
137
// -------------------------------------------------------------------------
138
// Scheduler thread implementation.
139
// This class provides the implementation of the scheduler specific parts
140
// of each thread.
141
 
142
class Cyg_SchedThread_Implementation
143
{
144
    friend class Cyg_Scheduler_Implementation;
145
    friend class Cyg_ThreadQueue_Implementation;
146
 
147
protected:
148
 
149
    cyg_priority        priority;       // current thread priority
150
 
151
    Cyg_SchedThread_Implementation(CYG_ADDRWORD sched_info);
152
 
153
    void yield();                       // Yield CPU to next thread
154
 
155
    // These are not applicable in a bitmap scheduler; placeholders:
156
    inline void rotate_queue( cyg_priority pri ) { };
157
    inline void to_queue_head( void ) { };
158
 
159
    inline void timeslice_save() {};
160
    inline void timeslice_restore() {};
161
    inline void timeslice_reset() {};
162
 
163
};
164
 
165
// -------------------------------------------------------------------------
166
// Thread queue implementation.
167
// This class provides the (scheduler specific) implementation of the
168
// thread queue class.
169
 
170
class Cyg_ThreadQueue_Implementation
171
{
172
    cyg_sched_bitmap    wait_queue;
173
 
174
protected:
175
 
176
    // API used by Cyg_ThreadQueue
177
 
178
    Cyg_ThreadQueue_Implementation();   // Constructor
179
 
180
                                        // Add thread to queue
181
    void                enqueue(Cyg_Thread *thread);
182
 
183
                                        // return first thread on queue
184
    Cyg_Thread          *highpri();
185
 
186
                                        // remove first thread on queue
187
    Cyg_Thread          *dequeue();
188
 
189
                                        // remove specified thread from queue
190
    void                remove(Cyg_Thread *thread);
191
 
192
                                        // test if queue is empty
193
    cyg_bool            empty();
194
 
195
};
196
 
197
inline cyg_bool Cyg_ThreadQueue_Implementation::empty()
198
{
199
    return wait_queue == 0;
200
}
201
 
202
// -------------------------------------------------------------------------
203
 
204
#endif // ifndef CYGONCE_KERNEL_BITMAP_HXX
205
// EOF bitmap.hxx

powered by: WebSVN 2.1.0

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