File: pdc.h

package info (click to toggle)
gridengine 8.1.9%2Bdfsg-10
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 56,880 kB
  • sloc: ansic: 432,689; java: 87,068; cpp: 31,958; sh: 29,429; jsp: 7,757; perl: 6,336; xml: 5,828; makefile: 4,701; csh: 3,928; ruby: 2,221; tcl: 1,676; lisp: 669; yacc: 519; python: 503; lex: 361; javascript: 200
file content (206 lines) | stat: -rw-r--r-- 6,940 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
#ifndef _PDC_H_
#define _PDC_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__*/

#include "err_trace.h"

/* The offsetof macro is part of ANSI C, but many compilers lack it, for
 * example "gcc -ansi"
  */
#if !defined (offsetof)
#  define offsetof(type, member) \
         ((size_t)((char *)&((type *)0L)->member - (char *)0L))
#endif

/*

   The following are some macros for managing doubly linked circular lists.
   These linked lists are linked together using the lnk_link_s structure. The
   next and prev pointers in the lnk_link_s structure always point to another
   lnk_link_s structure. This allows objects to easily reside on multiple
   lists by having multiple lnk_link_s structures in the object. To define
   an entry that will be linked in a list, you simply add the lnk_link_s to
   the object;

       typedef struct str_elem_s {
	  lnk_link_t link;
	  char *str;
       } str_elem_t;

   
   The head of a list is also a lnk_link_s structure. The next entry of the
   head link points to the first entry in the list. The prev entry of the head
   link points to the last entry in the list. The list is always maintained as
   a circular list which contains the head link. That is, the prev pointer of
   the first entry in the list points to the head link and the next pointer
   of the last entry in the list points to the head link. The LNK_INIT macro
   is used to initialize a list. Specifically, it sets up the head link.
   To define a list:

	lnk_link_t list;
	LNK_INIT(&list);

   The LNK_ADD routine adds an entry to a list. The entry identified by link2
   is inserted into a list before the entry identified as link1.  To add to
   the beginning of a list:

       str_elem_t *str = strdup("Hello world\n");

       LNK_ADD(list->next, &str->link);

   To add to the end of a list:

       LNK_ADD(list->prev, &str->link);

   The LNK_DATA macro returns the data associated with an element in the
   list. The arguments are the entry link, the structure name of the 
   entry object, and the link field. The LNK_DATA macros calculates where
   the data is based on where the link field is in the structure object.

       str_elem_t *elem;
       lnk_link_t *curr;

       for (curr=list.next; curr != &list; curr=curr->next) {
	  elem = LNK_DATA(curr, str_elem_t, link);
          puts(elem->str);
       }


   The LNK_DELETE macro removes an element from a list.

       while((curr=list.next) != &list) {
	   elem = LNK_DATA(curr, str_elem_t, link);
	   free(elem->str);
	   LNK_DELETE(curr);
       }

*/

typedef struct lnk_link_s {
    struct lnk_link_s   *next;
    struct lnk_link_s   *prev;
} lnk_link_t;

#define LNK_DATA(link, entry_type, link_field)  \
    ((entry_type *)((char *)(link) - offsetof(entry_type, link_field)))

#if 0
#define LNK_INIT(link)                          \
(                                               \
    (link)->next = (link),                      \
    (link)->prev = (link),                      \
    (link)                                      \
)
#endif
#define LNK_INIT(link)                          \
(                                               \
    (link)->next = (link),                      \
    (link)->prev = (link)                      \
)

#define LNK_ADD(link1, link2)                   \
{                                               \
    lnk_link_t  *zzzlink = (link1);             \
    (link2)->next = (zzzlink)->next;            \
    (link2)->prev = (zzzlink);                  \
    (zzzlink)->next->prev = (link2);            \
    (zzzlink)->next = (link2);                  \
}

#define LNK_DELETE(link)                        \
{                                               \
    lnk_link_t  *zzzlink = (link);              \
    (zzzlink)->prev->next = (zzzlink)->next;    \
    (zzzlink)->next->prev = (zzzlink)->prev;    \
}

typedef struct psJob_s psJob_t;
typedef struct psProc_s psProc_t;
typedef struct psStat_s psStat_t;
typedef struct psSys_s psSys_t;

typedef struct {
   lnk_link_t link;
   psJob_t job;
   lnk_link_t procs;
   lnk_link_t arses;
   time_t precreated;     /* set if job element created before psWatchJob */
   time_t starttime;
   time_t timeout;        /* completion timeout */
   double utime;          /* user time */
   double stime;          /* system time */
   double srtime;         /* time waiting on run queue */
   double bwtime;         /* time waiting for block I/O */
   double rwtime;         /* time waiting for raw I/O */
   uint64 mem;
   uint64 chars;
} job_elem_t;

typedef struct {
   lnk_link_t link;
   JobID_t jid;            
   psProc_t proc;
   double bwtime;
   double rwtime;
   double qwtime;
   uint64 chars;
   uint64 mem;             /* delta integral vmem */
   uint64 vmem;            /* virtual process size */
   uint64 rss;             /* resident set size */
   uint64 ru_ioblock;      /* # of block input operations */
   uint64 delta_chars;     /* number of chars to be added to jd_chars this time step */
#if defined(LINUX)
   uint64 iochars;         /* number of chars from previous load interval */
#endif
} proc_elem_t;

extern long pagesize;

#if defined(ALPHA) || defined(LINUX) || defined(SOLARIS) || defined(FREEBSD) || defined(DARWIN)
   void pdc_kill_addgrpid(gid_t, int, tShepherd_trace);
#endif

/*
 * Prototypes for external interface
 */

int		psStartCollector(void);
int		psStopCollector(void);
int		psWatchJob(JobID_t JobID);
int		psIgnoreJob(JobID_t JobID);
struct psStat_s	*psStatus(void);
struct psJob_s *psGetOneJob(JobID_t JobID);
struct psJob_s *psGetAllJobs(void);
struct psSys_s *psGetSysdata(void);

#endif /* _PDC_H_ */