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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [compat/] [posix/] [current/] [src/] [sched.cxx] - Blame information for rev 810

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

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

powered by: WebSVN 2.1.0

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