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

📄 schedinit.c

📁 openPBS的开放源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/**         OpenPBS (Portable Batch System) v2.3 Software License* * Copyright (c) 1999-2000 Veridian Information Solutions, Inc.* All rights reserved.* * ---------------------------------------------------------------------------* For a license to use or redistribute the OpenPBS software under conditions* other than those described below, or to purchase support for this software,* please contact Veridian Systems, PBS Products Department ("Licensor") at:* *    www.OpenPBS.org  +1 650 967-4675                  sales@OpenPBS.org*                        877 902-4PBS (US toll-free)* ---------------------------------------------------------------------------* * This license covers use of the OpenPBS v2.3 software (the "Software") at* your site or location, and, for certain users, redistribution of the* Software to other sites and locations.  Use and redistribution of* OpenPBS v2.3 in source and binary forms, with or without modification,* are permitted provided that all of the following conditions are met.* After December 31, 2001, only conditions 3-6 must be met:* * 1. Commercial and/or non-commercial use of the Software is permitted*    provided a current software registration is on file at www.OpenPBS.org.*    If use of this software contributes to a publication, product, or*    service, proper attribution must be given; see www.OpenPBS.org/credit.html* * 2. Redistribution in any form is only permitted for non-commercial,*    non-profit purposes.  There can be no charge for the Software or any*    software incorporating the Software.  Further, there can be no*    expectation of revenue generated as a consequence of redistributing*    the Software.* * 3. Any Redistribution of source code must retain the above copyright notice*    and the acknowledgment contained in paragraph 6, this list of conditions*    and the disclaimer contained in paragraph 7.* * 4. Any Redistribution in binary form must reproduce the above copyright*    notice and the acknowledgment contained in paragraph 6, this list of*    conditions and the disclaimer contained in paragraph 7 in the*    documentation and/or other materials provided with the distribution.* * 5. Redistributions in any form must be accompanied by information on how to*    obtain complete source code for the OpenPBS software and any*    modifications and/or additions to the OpenPBS software.  The source code*    must either be included in the distribution or be available for no more*    than the cost of distribution plus a nominal fee, and all modifications*    and additions to the Software must be freely redistributable by any party*    (including Licensor) without restriction.* * 6. All advertising materials mentioning features or use of the Software must*    display the following acknowledgment:* *     "This product includes software developed by NASA Ames Research Center,*     Lawrence Livermore National Laboratory, and Veridian Information *     Solutions, Inc.*     Visit www.OpenPBS.org for OpenPBS software support,*     products, and information."* * 7. DISCLAIMER OF WARRANTY* * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. ANY EXPRESS* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT* ARE EXPRESSLY DISCLAIMED.* * IN NO EVENT SHALL VERIDIAN CORPORATION, ITS AFFILIATED COMPANIES, OR THE* U.S. GOVERNMENT OR ANY OF ITS AGENCIES BE LIABLE FOR ANY DIRECT OR INDIRECT,* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.* * This license will be governed by the laws of the Commonwealth of Virginia,* without reference to its choice of law rules.*//* $Id: schedinit.c,v 1.1.10.4 2000/08/09 00:19:20 hender Exp $ */#define LIVE_DANGEROUSLY 1/* * Perform any scheduler initialization. */#include <sys/types.h>#include <sys/utsname.h>#include <ctype.h>#include <stdio.h>#include <signal.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <unistd.h>#include "pbs_ifl.h"#include "net_connect.h"#include "sched_cmds.h"#include "log.h"#include "toolkit.h"#include "gblxvars.h"/* * Flag register to prevent SIGHUP from causing a reconfiguration * while the current configuration is in use.  SCHD_SIGFLAGS_BUSY * is set when the scheduler is actively using the structs defined * by the configuration.  The SIGHUP handler sets the flag * SCHD_SIGFLAGS_RECONFIG which signals the scheduler to reconfigure * itself before beginning the next scheduling iteration. */volatile sig_atomic_t schd_sigflags = 0;/* * Declarations of global variables related to configuration *//* Queue lists. */QueueList  *schd_SubmitQueue		= NULL;QueueList  *schd_BatchQueues		= NULL;QueueList  *schd_DedQueues		= NULL;QueueList  *schd_SpecialQueue		= NULL;QueueList  *schd_ExternQueues		= NULL;int     schd_FirstRun		= 1;/* Scheduler configuration parameters */int     schd_TEST_ONLY			= 0;int     schd_AVOID_FRAGS		= 1;int     schd_SORT_BY_PAST_USAGE		= 1;int     schd_STARVATION_TIMEOUT		= 0;time_t  schd_ENFORCE_PRIME_TIME		= 0;int	schd_NONPRIME_DRAIN_SYS		= 0;time_t	schd_NP_DRAIN_BACKTIME		= 0;time_t	schd_NP_DRAIN_IDLETIME		= 0;time_t  schd_PRIME_TIME_START		= 0;time_t  schd_PRIME_TIME_END		= 0;time_t	schd_PT_SMALL_NODE_LIMIT	= 0;time_t	schd_PT_SMALL_WALLT_LIMIT	= 0;time_t	schd_PT_WALLT_LIMIT		= 0;time_t	schd_WALLT_LARGE_LIMIT		= 0;time_t	schd_WALLT_SMALL_LIMIT		= 0;time_t	schd_SMALL_JOB_MAX		= 0;int     schd_TARGET_LOAD_PCT		= 90;int     schd_TARGET_LOAD_MINUS		= 15;int     schd_TARGET_LOAD_PLUS		= 10;int     schd_HIGH_SYSTIME		= 0;int     schd_MAX_JOBS			= 0;int     schd_MIN_JOBS			= 0;int     schd_MAX_DEDICATED_JOBS		= 0;int     schd_MAX_USER_RUN_JOBS		= 10;time_t  schd_MAX_QUEUED_TIME		= 0;time_t  schd_SMALL_QUEUED_TIME		= 60 * 60 * 12;time_t	schd_INTERACTIVE_LONG_WAIT	= 0;int     schd_SCHED_RESTART_ACTION	= 0;time_t  schd_ENFORCE_ALLOCATION		= 0;time_t  schd_ENFORCE_DEDTIME		= 0;int	schd_DEDTIME_CACHE_SECS		= 0;int	schd_FAKE_MACH_MULT		= 1;int	schd_MANAGE_HPM			= 0;int	schd_REVOKE_HPM			= 0;char   *schd_SCHED_ACCT_DIR		= NULL;char   *schd_DEDTIME_COMMAND		= NULL;char   *schd_SYSTEM_NAME		= NULL;char   *schd_SERVER_HOST		= NULL;char   *schd_SCHED_HOST			= NULL;char   *schd_JOB_DUMPFILE		= NULL;double	schd_DECAY_FACTOR		= 0.75;double	schd_OA_DECAY_FACTOR		= 0.95;char    schd_ThisHost[PBS_MAXHOSTNAME];char   *schd_CmdStr[16];char   *schd_CfgFilename		= NULL;char   *schd_AllocFilename		= NULL;char   *schd_CurrentFilename		= NULL;static void catch_HUP (int signo);static void reset_config (void);static void create_sched_cmdstr (void);/* * Initialize the scheduler from the configuration and holidays files.   *//*ARGSUSED*/int schedinit(int argc, char *argv[]){    char   *id = "schedinit";    struct utsname name;    struct sigaction act, oact;    char   *ptr, canon[PBS_MAXHOSTNAME + 1];    size_t  len;    DBPRT(("\n%s\n", schd_VersionString));    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, 	schd_VersionString);    /*      * If this is the initial startup configuration, then schd_TimeNow will     * be 0.  Initialize it to the current time, so it can be tested against     * various times when initializing.     */    if (schd_TimeNow == 0) {	schd_TimeNow = time(NULL);	DBPRT(("%s: initialize/startup at %s", id, ctime(&schd_TimeNow)));    }    /*     * Determine location of configuration file.  Check for the presence of     * the PBSSCHED_CONFIG environment variable.  If not defined, fall back      * to the compiled default CONFIGFILE.     *      * Since neither the environment variables nor the compiled-in default     * can be changed (with the exception of someone wreaking havoc with     * a debugger or something), this only needs to be done once.     */    if (schd_CfgFilename == NULL) {	ptr = getenv("PBSSCHED_CONFIG");	if (ptr == NULL)	    ptr = CONFIGFILE;	schd_CfgFilename = schd_strdup(ptr);	if (schd_CfgFilename == NULL) {	    (void)sprintf(log_buffer, "schd_strdup() failed for configfile");	    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);	    DBPRT(("%s: %s\n", id, log_buffer));	    return (-1);	}    }    /*      * From this point on, goto cleanup_and_error: to clean up any allocated      * storage for filenames.     */    DBPRT(("SCHEDINIT: Reading configuration from '%s'\n", schd_CfgFilename));    /* Reset the configuration to a "known" state. */    reset_config();    /* Determine on what host this scheduler running. */    uname(&name);    if (get_fullhostname(name.nodename, canon, PBS_MAXHOSTNAME) == 0) {	strncpy(schd_ThisHost, canon, PBS_MAXHOSTNAME);    } else {	(void)sprintf(log_buffer, 	    "Failed to canonicalize uname %s (using it anyway)",	    name.nodename);	log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);	DBPRT(("%s: %s\n", id, log_buffer));	strncpy(schd_ThisHost, name.nodename, PBS_MAXHOSTNAME);    }    schd_lowercase(schd_ThisHost);    DBPRT(("%s: This host is '%s'\n", id, schd_ThisHost));    /*      * Register the state of the config file.  The call to reset_config()     * above will have cleared all file watches.     */    if (schd_register_file(schd_CfgFilename)) {	(void)sprintf(log_buffer, "cannot watch %s", schd_CfgFilename);	log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);	DBPRT(("%s: %s\n", id, log_buffer));	goto cleanup_and_error;    }    /* Read the configuration file. */    if (schd_get_config(schd_CfgFilename))	return (-1);    /*     * Register the state of the holidays file.  This allows schd_req() to     * reload it if it is changed.     */    if (schd_register_file(HOLIDAYS_FILE)) {	(void)sprintf(log_buffer, "cannot watch %s", HOLIDAYS_FILE);	log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);	DBPRT(("%s: %s\n", id, log_buffer));	goto cleanup_and_error;    }    /* Get a list of prime/non-prime times from the holidays file */

⌨️ 快捷键说明

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