~ubuntu-branches/ubuntu/precise/torque/precise-updates

« back to all changes in this revision

Viewing changes to src/server/svr_resccost.c

  • Committer: Bazaar Package Importer
  • Author(s): Dominique Belhachemi
  • Date: 2010-05-17 20:56:46 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20100517205646-yjsoqs5r1s9xpnu9
Tags: upstream-2.4.8+dfsg
ImportĀ upstreamĀ versionĀ 2.4.8+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
#include "pbs_error.h"
93
93
#include "server_limits.h"
94
94
#include "server.h"
95
 
#include "job.h"
 
95
#include "pbs_job.h"
96
96
 
97
97
/*
98
98
 * This file contains the functions for manipulating the server
241
241
/*ARGSUSED*/
242
242
 
243
243
 
244
 
int encode_rcost(attr, phead, atname, rsname, mode)
245
 
attribute *attr;   /* ptr to attribute */
246
 
tlist_head *phead;   /* head of attrlist list */
247
 
char  *atname;  /* attribute name */
248
 
char  *rsname;  /* resource name or null */
249
 
int  mode;   /* encode mode, unused here */
 
244
int encode_rcost(
 
245
 
 
246
  attribute *attr,   /* ptr to attribute */
 
247
  tlist_head *phead,   /* head of attrlist list */
 
248
  char  *atname,  /* attribute name */
 
249
  char  *rsname,  /* resource name or null */
 
250
  int  mode)   /* encode mode, unused here */
 
251
 
250
252
  {
251
253
  svrattrl *pal;
252
254
 
253
255
  struct resource_cost *pcost;
254
256
 
255
257
  if (!attr)
256
 
    return (-1);
 
258
    {
 
259
    /* FAILURE */
 
260
 
 
261
    return(-1);
 
262
    }
257
263
 
258
264
  if (!(attr->at_flags & ATR_VFLAG_SET))
259
 
    return (0);
 
265
    {
 
266
    /* NO-OP */
 
267
 
 
268
    return(0);
 
269
    }
260
270
 
261
271
  pcost = (struct resource_cost *)GET_NEXT(attr->at_val.at_list);
262
272
 
263
 
  while (pcost)
 
273
  while (pcost != NULL)
264
274
    {
265
275
    rsname = pcost->rc_def->rs_name;
266
276
 
267
 
    if ((pal = attrlist_create(atname, rsname, 23)) == (svrattrl *)0)
268
 
      return (-1);
269
 
 
270
 
    (void)sprintf(pal->al_value, "%ld", pcost->rc_cost);
 
277
    if ((pal = attrlist_create(atname, rsname, 23)) == NULL)
 
278
      {
 
279
      /* FAILURE */
 
280
 
 
281
      return(-1);
 
282
      }
 
283
 
 
284
    sprintf(pal->al_value, "%ld",
 
285
 
 
286
            pcost->rc_cost);
271
287
 
272
288
    pal->al_flags = attr->at_flags;
273
289
 
276
292
    pcost = (struct resource_cost *)GET_NEXT(pcost->rc_link);
277
293
    }
278
294
 
279
 
  return (1);
 
295
  return(1);
280
296
  }
281
297
 
 
298
 
 
299
 
 
300
 
 
301
 
282
302
/*
283
303
 * set_rcost - set attribute A to attribute B,
284
304
 * either A=B, A += B, or A -= B
347
367
 * free_rcost - free space used by resource cost attribute
348
368
 */
349
369
 
350
 
void free_rcost(pattr)
351
 
attribute *pattr;
 
370
void
 
371
free_rcost(attribute *pattr)
352
372
  {
353
373
 
354
374
  struct resource_cost *pcost;
371
391
 * cost is per unit.
372
392
 */
373
393
 
374
 
long calc_job_cost(pjob)
375
 
job *pjob;
 
394
long
 
395
calc_job_cost(job *pjob)
376
396
  {
377
397
  long      amt;
378
398
  long      cost = 0;