CPN
Computational Process Networks
PthreadScheduleParam.h
Go to the documentation of this file.
1 //=============================================================================
2 // PthreadScheduleParam class
3 //-----------------------------------------------------------------------------
4 // POSIX Pthread class library
5 // Copyright (C) 1997-1999 The University of Texas
6 //
7 // This library is free software; you can redistribute it and/or modify it
8 // under the terms of the GNU Library General Public License as published
9 // by the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
11 //
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // Library General Public License for more details.
16 //
17 // The GNU Public License is available in the file LICENSE, or you
18 // can write to the Free Software Foundation, Inc., 59 Temple Place -
19 // Suite 330, Boston, MA 02111-1307, USA, or you can find it on the
20 // World Wide Web at http://www.fsf.org.
21 //=============================================================================
22 
23 #ifndef PthreadScheduleParam_h
24 #define PthreadScheduleParam_h
25 #pragma once
26 
27 #ifdef EXTERNAL_TEMPLATES
28 # pragma interface
29 #endif
30 
31 #include <cpn/common.h>
33 
34 #if defined(OS_AIX)
35  #include <sys/sched.h>
36 #else
37  #include <sched.h>
38 #endif
39 
40 
42  public:
44  PthreadScheduleParam(int priority) { param.sched_priority = priority; }
45  operator sched_param* (void) { return &param; }
46 
47  int Priority(int priority) { return param.sched_priority = priority; }
48  int Priority(void) const { return param.sched_priority; }
49 
50  #ifdef _POSIX_PRIORITY_SCHEDULING
51  static int PriorityMax(int policy) { return sched_get_priority_max(policy); }
52  static int PriorityMin(int policy) { return sched_get_priority_min(policy); }
53 
54  static void Yield(void) { sched_yield(); }
55  #endif
56 
57  private:
58  sched_param param;
59 };
60 
61 
62 #endif
int Priority(int priority)
PthreadScheduleParam(int priority)
int Priority(void) const