OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [kernel/] [v2_0/] [include/] [bitmap.hxx] - Blame information for rev 252

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

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

powered by: WebSVN 2.1.0

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