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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [compat/] [posix/] [v2_0/] [src/] [sched.cxx] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//      sched.cxx
4
//
5
//      POSIX scheduler API implementation
6
//
7
//==========================================================================
8
//####ECOSGPLCOPYRIGHTBEGIN####
9
// -------------------------------------------
10
// This file is part of eCos, the Embedded Configurable Operating System.
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under
14
// the terms of the GNU General Public License as published by the Free
15
// Software Foundation; either version 2 or (at your option) any later version.
16
//
17
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20
// for more details.
21
//
22
// You should have received a copy of the GNU General Public License along
23
// with eCos; if not, write to the Free Software Foundation, Inc.,
24
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
//
26
// As a special exception, if other files instantiate templates or use macros
27
// or inline functions from this file, or you compile this file and link it
28
// with other works to produce a work based on this file, this file does not
29
// by itself cause the resulting work to be covered by the GNU General Public
30
// License. However the source code for this file must still be made available
31
// in accordance with section (3) of the GNU General Public License.
32
//
33
// This exception does not invalidate any other reasons why a work based on
34
// this file might be covered by the GNU General Public License.
35
//
36
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37
// at http://sources.redhat.com/ecos/ecos-license/
38
// -------------------------------------------
39
//####ECOSGPLCOPYRIGHTEND####
40
//==========================================================================
41
//#####DESCRIPTIONBEGIN####
42
//
43
// Author(s):           nickg
44
// Contributors:        nickg
45
// Date:                2000-03-27
46
// Purpose:             POSIX scheduler API implementation
47
// Description:         This file contains the implementation of the POSIX scheduler
48
//                      functions.
49
//              
50
//              
51
//
52
//####DESCRIPTIONEND####
53
//
54
//==========================================================================
55
 
56
#include <pkgconf/hal.h>
57
#include <pkgconf/kernel.h>
58
#include <pkgconf/posix.h>
59
 
60
#include <cyg/kernel/ktypes.h>         // base kernel types
61
#include <cyg/infra/cyg_trac.h>        // tracing macros
62
#include <cyg/infra/cyg_ass.h>         // assertion macros
63
 
64
#include "pprivate.h"                   // POSIX private header
65
 
66
#include <cyg/kernel/sched.hxx>        // scheduler definitions
67
#include <cyg/kernel/thread.hxx>       // thread definitions
68
 
69
#include <cyg/kernel/sched.inl>        // scheduler inlines
70
#include <cyg/kernel/thread.inl>       // thread inlines
71
 
72
//==========================================================================
73
// Process scheduling functions.
74
 
75
//--------------------------------------------------------------------------
76
// Set scheduling parameters for given process.
77
 
78
int sched_setparam (pid_t pid, const struct sched_param *param)
79
{
80
    CYG_REPORT_FUNCTYPE( "returning %d" );
81
 
82
    if( pid != 0 )
83
    {
84
        errno = ESRCH;
85
        CYG_REPORT_RETVAL( -1 );
86
        return -1;
87
    }
88
 
89
    errno = ENOSYS;
90
    CYG_REPORT_RETVAL( -1 );
91
    return -1;
92
}
93
 
94
//--------------------------------------------------------------------------
95
// Get scheduling parameters for given process.
96
 
97
int sched_getparam (pid_t pid, struct sched_param *param)
98
{
99
    CYG_REPORT_FUNCTYPE( "returning %d" );
100
 
101
    if( pid != 0 )
102
    {
103
        errno = ESRCH;
104
        CYG_REPORT_RETVAL( -1 );
105
        return -1;
106
    }
107
 
108
    errno = ENOSYS;
109
    CYG_REPORT_RETVAL( -1 );
110
    return -1;
111
}
112
 
113
//--------------------------------------------------------------------------
114
// Set scheduling policy and/or parameters for given process.
115
int sched_setscheduler (pid_t pid,
116
                        int policy,
117
                        const struct sched_param *param)
118
{
119
    CYG_REPORT_FUNCTYPE( "returning %d" );
120
 
121
    if( pid != 0 )
122
    {
123
        errno = ESRCH;
124
        CYG_REPORT_RETVAL( -1 );
125
        return -1;
126
    }
127
 
128
    errno = ENOSYS;
129
    CYG_REPORT_RETVAL( -1 );
130
    return -1;
131
}
132
 
133
 
134
//--------------------------------------------------------------------------
135
// Get scheduling policy for given process.
136
 
137
int sched_getscheduler (pid_t pid)
138
{
139
    CYG_REPORT_FUNCTYPE( "returning %d" );
140
 
141
    if( pid != 0 )
142
    {
143
        errno = ESRCH;
144
        CYG_REPORT_RETVAL( 0 );
145
        return -1;
146
    }
147
 
148
    errno = ENOSYS;
149
    CYG_REPORT_RETVAL( -1 );
150
    return -1;
151
}
152
 
153
//--------------------------------------------------------------------------
154
// Force current thread to relinquish the processor.
155
 
156
int sched_yield (void)
157
{
158
    CYG_REPORT_FUNCTYPE( "returning %d" );
159
 
160
    Cyg_Thread::yield();
161
 
162
    CYG_REPORT_RETVAL( 0 );
163
    return 0;
164
}
165
 
166
 
167
//==========================================================================
168
// Scheduler parameter limits.
169
 
170
//--------------------------------------------------------------------------
171
// Get maximum priority value for a policy.
172
 
173
int sched_get_priority_max (int policy)
174
{
175
    CYG_REPORT_FUNCTYPE( "returning %d" );
176
 
177
    if( policy != SCHED_FIFO &&
178
        policy != SCHED_RR &&
179
        policy != SCHED_OTHER )
180
    {
181
        errno = EINVAL;
182
        CYG_REPORT_RETVAL( -1 );
183
        return -1;
184
    }
185
 
186
    int pri = PTHREAD_POSIX_PRIORITY( CYG_THREAD_MAX_PRIORITY );
187
 
188
    CYG_REPORT_RETVAL( pri );
189
    return pri;
190
}
191
 
192
//--------------------------------------------------------------------------
193
// Get minimum priority value for a policy.
194
 
195
int sched_get_priority_min (int policy)
196
{
197
    CYG_REPORT_FUNCTYPE( "returning %d" );
198
 
199
    if( policy != SCHED_FIFO &&
200
        policy != SCHED_RR &&
201
        policy != SCHED_OTHER )
202
    {
203
        errno = EINVAL;
204
        CYG_REPORT_RETVAL( -1 );
205
        return -1;
206
    }
207
 
208
    // idle thread priority isn't valid for general use, so subtract 1
209
    int pri = PTHREAD_POSIX_PRIORITY( CYG_THREAD_MIN_PRIORITY-1 );
210
 
211
    CYG_REPORT_RETVAL( pri );
212
    return pri;
213
}
214
 
215
//--------------------------------------------------------------------------
216
// Get the SCHED_RR interval for the given process.
217
 
218
int sched_rr_get_interval (pid_t pid, struct timespec *t)
219
{
220
    CYG_REPORT_FUNCTYPE( "returning %d" );
221
 
222
#ifdef CYGPKG_POSIX_CLOCKS
223
    if( pid != 0 )
224
    {
225
        errno = ESRCH;
226
        CYG_REPORT_RETVAL( -1 );
227
        return -1;
228
    }
229
 
230
    cyg_ticks_to_timespec( CYGNUM_KERNEL_SCHED_TIMESLICE_TICKS, t );
231
 
232
    CYG_REPORT_RETVAL( 0 );
233
    return 0;
234
#else
235
    errno = ENOSYS;
236
    CYG_REPORT_RETVAL( -1 );
237
    return -1;
238
#endif
239
}
240
 
241
// -------------------------------------------------------------------------
242
// EOF sched.cxx

powered by: WebSVN 2.1.0

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