⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jobinfo.c

📁 openPBS的开放源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
	    }	    p = NULL;	    tmp_p = strstr(var_p, "PBS_O_QUEUE");	    if (tmp_p) {		p = strtok(tmp_p, "=");		p = strtok(NULL,  ", ");	    }	    if (p != NULL) {		job->oqueue = schd_strdup(p);	    } else {		/* if the originating queue is unknown, default		 * to the locally defined "submit" queue.		 */		job->oqueue = schd_strdup(schd_SubmitQueue->queue->qname);	    }	    free(var_p);	    changed ++;	    continue;	}	if (!strcmp(attr->name, ATTR_l)) {	    if (!strcmp(attr->resource, "walltime")) {		job->walltime = schd_val2sec(attr->value);		changed ++;	    } else if (!strcmp(attr->resource,"ncpus")) {		cpu_req = atoi(attr->value);		job->nodes = MAX(job->nodes, NODES_FROM_CPU(cpu_req));		changed ++;	    } else if (!strcmp(attr->resource,"mem")) {		mem_req = schd_val2byte(attr->value);		job->nodes = MAX(job->nodes, NODES_FROM_MEM(mem_req));		changed ++;#ifdef NODEMASK	    } else if (!strcmp(attr->resource,"nodemask")) {		if (schd_str2mask(attr->value, &job->nodemask)) {		    (void)sprintf(log_buffer,			"bad nodemask %s for job %s", attr->value, job->jobid);		    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, 			log_buffer);		} else 		    changed++;	/* Job nodemask was valid. */#endif	/* NODEMASK */	    } 	    if (!strcmp(attr->resource, HPM_ATTRIBUTE)) {		/* 		 * If the job requests hpm support, set the flag, otherwise		 * turn it off.		 */		if (schd_val2bool(attr->value, &istrue) == 0) {		    if (istrue)			job->flags |= JFLAGS_NEEDS_HPM;		    else			job->flags &= ~JFLAGS_NEEDS_HPM;		    changed ++;		} else {		    DBPRT(("%s: can't parse %s = %s into boolean\n", id,			attr->name, attr->value));		}	    }	    /* That's all for requested resources. */	    continue;	}	if (!strcmp(attr->name, ATTR_used)) {   	    if (!strcmp(attr->resource, "walltime")) {		job->walltime_used = schd_val2sec(attr->value);		changed ++;	    }	    /* No other interesting cases. */	    continue;	}	/* Creation time attribute. */	if (!strcmp(attr->name, ATTR_ctime)) {	    /* How long ago was it put in the queue ? */	    job->time_queued = schd_TimeNow - atoi(attr->value);	    continue;	}	/* Modified time attribute. */	if (!strcmp(attr->name, ATTR_mtime)) {	    /* When was the job last modified? */	    job->mtime = atoi(attr->value);	    continue;	}#ifdef ATTR_etime	/* 	 * When was the job last eligible to run?  When a user-hold is	 * released, this value is updated to the current time.  This	 * prevents users from gaining higher priority from holding their	 * jobs.	 */	if (!strcmp(attr->name, ATTR_etime)) {	    job->eligible = schd_TimeNow - atoi(attr->value);	    continue;	}#endif /* ATTR_etime */    }    /*      * If this job is in the "Running" state, compute how many seconds      * remain until it is completed.     */    if (job->state == 'R') {	job->time_left = job->walltime - job->walltime_used;    }     /*     * If this job was enqueued since the last time we ran, set the job     * flag to indicate that we have not yet seen this job.  This makes it     * a candidate for additional processing.  There may be some inaccuracy,     * since the time_t has resolution of 1 second.  Attempt to err on the     * side of caution.     */    if ((job->state == 'Q') && (job->time_queued != UNSPECIFIED)) {        if (job->time_queued <= (schd_TimeNow - schd_TimeLast)) {	    job->flags |= JFLAGS_FIRST_SEEN;	}    }    /*     * If the 'etime' attribute wasn't found, set it to the time the job has     * been queued.  Most jobs will be eligible to run their entire lifetime.     * The exception is a job that has been held - if it was a user hold,     * the release will reset the etime to the latest value.     * If not eligible time was given, use the job's creation time.     */    if (!job->eligible)	job->eligible = job->time_queued;    /*     * If the job provided a memory or CPU resource that does not match     * the resources that will be allocated by the assigned nodes (i.e.     * a request for 100mb of memory and 16 CPUs - the job will "get" all     * 4GB of memory anyway), alter the job attributes such that they     * will align with the assigned nodes later.     */    bump_rsrc_requests(job, cpu_req, mem_req);    return (changed);}/* * Walk a list of jobs, freeing any information on them and then freeing * each element.  Returns number of elements freed. */intschd_free_jobs(Job *list){    Job    *job, *next;    int     numjobs = 0;    for (job = list; job != NULL; job = next) {        numjobs ++;	next = job->next;	if (job->jobid)		free(job->jobid);	if (job->owner)		free(job->owner);	if (job->host)		free(job->host);	if (job->exechost)	free(job->exechost);	if (job->group)		free(job->group);	if (job->comment)	free(job->comment);	if (job->oqueue)	free(job->oqueue);	/*	 * Do *not* free the Job's backpointer to the queue's name if it	 * is a reference to the Queue's qname.  If it is local storage	 * created by schd_strdup(), it should be freed to prevent a 	 * memory leak.	 */	if (job->flags & JFLAGS_QNAME_LOCAL)	    free(job->qname);	free(job);    }    return (numjobs);}static int bump_rsrc_requests(Job *job, int cpu_req, size_t mem_req){    char   *id = "bump_rsrc_requests";    char   *val;    char    buf[64];    int     bumped = 0;    /*      * If a job gives the "wrong" value for the memory request (for the     * number of nodes required to fulfill the request), then bump the     * memory request to the amount of memory the assigned nodes would     * consume.     */    if ((mem_req == 0) || (mem_req != (job->nodes * MB_PER_NODE))) {	/* Make a printable version of the requested memory. */	strcpy(buf, schd_byte2val(mem_req));	/* Compute the "right" memory request, based on the nodes. */	val = schd_byte2val(job->nodes * MB_PER_NODE);	if (val == NULL)	    return (1);	if (schd_alterjob(connector, job, ATTR_l, val, "mem")) {	    DBPRT(("%s: Failed to set job %s \"mem\" attr to %s\n", id,		job->jobid, val));	    return (1);	}	bumped++;    }    /*      * If a job gives the "wrong" value for the CPU request (for the     * number of nodes required to fulfill the request), then bump the     * CPU request to the number of CPUs the assigned nodes would     * consume.     */    if ((cpu_req == 0) || (cpu_req != (job->nodes * PE_PER_NODE))) {	/* Compute the "right" memory request, based on the nodes. */	sprintf(buf, "%d", (job->nodes * PE_PER_NODE));	if (schd_alterjob(connector, job, ATTR_l, buf, "ncpus")) {	    DBPRT(("%s: Failed to set job %s \"ncpus\" attr to %s\n", id,		job->jobid, buf));	    return (1);	}	bumped++;    }    if (bumped) {	strncpy(buf, schd_byte2val(job->nodes * MB_PER_NODE), sizeof(buf) - 1);	sprintf(log_buffer, "%s cpu/mem (%d/%s) bumped to %d/%s (%d nodes)", 	    job->jobid, cpu_req, schd_byte2val(mem_req), 	    job->nodes * PE_PER_NODE, buf, job->nodes);	log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);	DBPRT(("%s: %s\n", id, log_buffer));    }    return (0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -