File: ptf.h

package info (click to toggle)
gridengine 8.1.9%2Bdfsg-13.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 57,140 kB
  • sloc: ansic: 432,689; java: 87,068; cpp: 31,958; sh: 29,445; jsp: 7,757; perl: 6,336; xml: 5,828; makefile: 4,704; csh: 3,934; ruby: 2,221; tcl: 1,676; lisp: 669; yacc: 519; python: 503; lex: 361; javascript: 200
file content (217 lines) | stat: -rw-r--r-- 6,114 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#ifndef __PTF_H
#define __PTF_H
/*___INFO__MARK_BEGIN__*/
/*************************************************************************
 * 
 *  The Contents of this file are made available subject to the terms of
 *  the Sun Industry Standards Source License Version 1.2
 * 
 *  Sun Microsystems Inc., March, 2001
 * 
 * 
 *  Sun Industry Standards Source License Version 1.2
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.2 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 * 
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 * 
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 * 
 *   Copyright: 2001 by Sun Microsystems, Inc.
 * 
 *   All Rights Reserved.
 * 
 ************************************************************************/
/*___INFO__MARK_END__*/

/*----------------------------------------------------
 * ptf.h
 *
 *--------------------------------------------------*/
  


#include <sys/types.h>

#if defined(IRIX)
#  include <sys/types.h>
#  include <sys/time.h>

   /* define some IRIX 6.[23] stuff not available in IRIX 6.4 */
   struct sched_deadline {
        timespec_t             dl_period;      /* size of deadline interval */
        timespec_t             dl_alloc;       /* cpu wanted in interval */
        /*
         * These fields are placeholders for future functionality.
         * They currently should be set to zero.
         */
        timespec_t              dl_deadline;    /* if deadline/period differ */
        int                     dl_flags;       /* control flags */
   };
#  define DEADLINE 15
#endif

#define PTF_COMPENSATION_FACTOR 2.0

#if defined(IRIX)
   typedef ash_t osjobid_t;
   typedef unsigned long long u_osjobid_t;
#  define OSJOBID_FMT "%lld"
/*#elif defined(ALPHA5)
   typedef unsigned long osjobid_t;
   typedef unsigned long u_osjobid_t;
#  define OSJOBID_FMT "%ld"       */
#else
   typedef pid_t osjobid_t;
   typedef unsigned int u_osjobid_t;
#  define OSJOBID_FMT pid_t_fmt
#endif

typedef gid_t addgrpid_t;
#define ADDGRPID_FMT gid_t_fmt  

/* job states */

#define JL_JOB_ACTIVE	0x00
#define JL_JOB_COMPLETE	0x01
#define JL_JOB_DELETED	0x02

/*-----------------------------------------------------

    PTF constants

*/

#define PTF_SCHEDULE_TIME 2

#define PTF_USAGE_DECAY_FACTOR 1.0

/* #define PTF_MIN_JOB_USAGE 0.001 */
#define PTF_MIN_JOB_USAGE 1.0

#define PTF_NICE_BASED

#define PTF_DIFF_DECAY_CONSTANT 0.8

#ifdef PTF_NICE_BASED
#  if defined(IRIX)
#    define ENFORCE_PRI_RANGE     1
#    define PTF_MIN_PRIORITY      (TS_PRIO_MIN)
#    define PTF_MAX_PRIORITY      (TS_PRIO_MAX)
#    define PTF_OS_MIN_PRIORITY   (TS_PRIO_MIN)
#    define PTF_OS_MAX_PRIORITY   (TS_PRIO_MAX)
#    define PTF_BACKGROUND_NICE_VALUE 20
#  elif defined(SOLARIS) || defined(ALPHA) || defined(DARWIN) || defined(FREEBSD) || defined(NETBSD)
#    define ENFORCE_PRI_RANGE     1
#    define PTF_MIN_PRIORITY      20
#    define PTF_MAX_PRIORITY     -10
#    define PTF_OS_MIN_PRIORITY   20
#    define PTF_OS_MAX_PRIORITY  -20
#  elif defined(LINUX) || defined(INTERIX) || defined(AIX)
#    define ENFORCE_PRI_RANGE     1
#    define PTF_MIN_PRIORITY      20
#    define PTF_MAX_PRIORITY      0
#    define PTF_OS_MIN_PRIORITY   20
#    define PTF_OS_MAX_PRIORITY  -20
#  elif defined(HP1164)
#    define ENFORCE_PRI_RANGE     1
#    define PTF_MIN_PRIORITY      39
#    define PTF_MAX_PRIORITY      0
#    define PTF_OS_MIN_PRIORITY   39
#    define PTF_OS_MAX_PRIORITY   0
#  endif
#  define PTF_BACKGROUND_JOB_PROPORTION 0.015
#  define PTF_BACKGROUND_JOB_PRIORITY NDPLOMAX
#endif

#ifdef IRIX
   /*
    * transform the priority value which will be accepted by
    * setpriority into a value which will be accepted by
    * schedctl
    */
#  define PTF_PRIORITY_TO_NATIVE_PRIORITY(priority) (priority+20)
#else
#  define PTF_PRIORITY_TO_NATIVE_PRIORITY(priority) (priority)
#endif


#ifdef PTF_NDPRI_BASED
#define PTF_MIN_PRIORITY NDPNORMMIN
/* #define PTF_MAX_PRIORITY NDPNORMMAX */
#define PTF_MAX_PRIORITY (NDPNORMMIN-10)
/*
#define PTF_MIN_PRIORITY NDPLOMIN
#define PTF_MAX_PRIORITY NDPLOMAX
*/
#endif


#ifdef PTF_SLICE_BASED
#define PTF_MIN_PRIORITY 1
#define PTF_MAX_PRIORITY 1000
#define PTF_TIME_TO_SLICE_UP 500   /* milliseconds */
#define PTF_MIN_SLICE        0.1    /* milliseconds */
#endif


/*-----------------------------------------------------

   PTF library

*/

int ptf_init(void);

void ptf_start(void); 

void ptf_stop(void); 

int ptf_is_running(void); 

void ptf_unregister_registered_job(u_long32 job_id, u_long32 ja_task_id );

void ptf_reinit_queue_priority(u_long32 job_id, u_long32 ja_task_idr, 
                               const char *pe_task_id_str, int priority);

int ptf_job_started(osjobid_t os_jobid, const char *task_id_str, 
                    lListElem *job, u_long32 jataskid);

int ptf_get_usage(lList **jobs);

lList *ptf_get_job_usage(u_long job_id, u_long ja_task_id, 
                         const char *task_id);

int ptf_process_job_ticket_list(lList *jobs);

int ptf_job_complete(u_long32 job_id, u_long32 ja_task_id, const char *pe_task_id, lList **usage);

void ptf_update_job_usage(void);

int ptf_adjust_job_priorities(void);

const char *ptf_errstr(int ptf_error_code);

void ptf_show_registered_jobs(void);

/*-----------------------------------------------------

    PTF errors
*/

/* #define PTF_Exxxx 1 */

#define PTF_ERROR_NONE                  0
#define PTF_ERROR_JOB_NOT_FOUND         1
#define PTF_ERROR_INVALID_ARGUMENT      2

#endif /* __PTF_H */