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

📄 schedinit.c

📁 openPBS的开放源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
    if (schd_read_holidays() < 0)	return (-1);    /*     * SCHED_ACCT_DIR is a configuration option.  Thus, the allocations     * and current file may change location or may go away if the      * ENFORCE_ALLOCATION option is turned off.  If they are needed,     * allocate space for the filenames, create the filenames from the      * schd_SCHED_ACCT_DIR and trailing pathnames, and then register      * them with the file watcher.     */    if (schd_AllocFilename != NULL)	free(schd_AllocFilename);    if (schd_CurrentFilename != NULL)	free(schd_CurrentFilename);    if (schd_ENFORCE_ALLOCATION && schd_TimeNow >= schd_ENFORCE_ALLOCATION) {	len = strlen(schd_SCHED_ACCT_DIR);	schd_AllocFilename = (char *)malloc(len + strlen("/allocations") + 1);	if (schd_AllocFilename == NULL) {	    (void)sprintf(log_buffer, 		"malloc() failed for allocations filename");	    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);	    DBPRT(("%s: %s\n", id, log_buffer));	    goto cleanup_and_error;	}	schd_CurrentFilename = (char *)malloc(len + strlen("/current") + 1);	if (schd_CurrentFilename == NULL) {	    (void)sprintf(log_buffer, 		"malloc() failed for current filename");	    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);	    DBPRT(("%s: %s\n", id, log_buffer));	    goto cleanup_and_error;	}	(void)sprintf(schd_AllocFilename, 	    "%s/allocations", schd_SCHED_ACCT_DIR);	(void)sprintf(schd_CurrentFilename, 	    "%s/current", schd_SCHED_ACCT_DIR);	if (schd_register_file(schd_AllocFilename)) {	    (void)sprintf(log_buffer, 		"Cannot watch %s", schd_AllocFilename);	    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);	    DBPRT(("%s: %s\n", id, log_buffer));	    goto cleanup_and_error;	}	if (schd_register_file(schd_CurrentFilename)) {	    (void)sprintf(log_buffer, 		"Cannot watch %s", schd_CurrentFilename);	    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);	    DBPRT(("%s: %s\n", id, log_buffer));	    goto cleanup_and_error;	}    }    /*      * Set up a signal handler for SIGHUP.  catch_HUP() will re-read the     * configuration file.     */    act.sa_flags   = 0;    act.sa_handler = catch_HUP;    sigemptyset(&act.sa_mask);    if (sigaction(SIGHUP, &act, &oact)) {	(void)sprintf(log_buffer, "Failed to setup SIGHUP handler.");	log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);	DBPRT(("%s: %s\n", id, log_buffer));    }    DBPRT(("SCHEDINIT: configuration complete.\n"));    return (0);cleanup_and_error:    /*      * Some error occurred.  Remove watches and free the storage allocated     * for the filenames.     */    if (schd_CfgFilename) {	schd_forget_file(schd_CfgFilename);	free(schd_CfgFilename);    }    if (schd_AllocFilename) {	schd_forget_file(schd_AllocFilename);	free(schd_AllocFilename);    }    if (schd_CurrentFilename) {	schd_forget_file(schd_CurrentFilename);	free(schd_CurrentFilename);    }    schd_CfgFilename     = NULL;    schd_AllocFilename   = NULL;    schd_CurrentFilename = NULL;    return (-1);}/*ARGSUSED*/static voidcatch_HUP(int signo){    /*      * Arrange for the configuration file to be re-read before the next     * scheduling iteration.  It is not safe (due to global state in the     * C library) to use any stream-based I/O (c.f. POSIX1003.1, Section     * 3.3.1.3, note 3f).     *     * However, if you are willing to live dangerously, you could      * reconfigure if the scheduler is not using the structs.     */#ifdef LIVE_DANGEROUSLY    /*      * If the scheduler is not busy, reconfigure on the fly.     * next run.  Otherwise, just do it.  You may lose badly doing this.     */    if (!(schd_sigflags & SCHD_SIGFLAGS_BUSY)) {	DBPRT(("Caught a SIGHUP.  Reconfiguring.\n"));	if (schedinit(0, NULL))	    exit(0);	return;    } else	DBPRT(("Caught a SIGHUP.  Scheduling reconfiguration when idle.\n"));#endif /* LIVE_DANGEROUSLY */    /* Arrange for the scheduler to reconfigure itself next time around. */    schd_sigflags |= SCHD_SIGFLAGS_RECONFIG;    return;}/* * Reset the scheduler's configuration to a "known" state. */static voidreset_config (void){    /* char   *id = "reset_config"; */    /*      * Clear out any contents of the lists previously defined.     */    if (schd_SubmitQueue)		schd_destroy_qlist(schd_SubmitQueue);    if (schd_BatchQueues)		schd_destroy_qlist(schd_BatchQueues);    /*      * These "queue lists" should always be degenerate lists (only 1     * element on them).  The schd_destroy_qlist() routine doesn't know the     * difference, and works fine with these.     */    if (schd_SpecialQueue)		schd_destroy_qlist(schd_SpecialQueue);    if (schd_DedQueues)			schd_destroy_qlist(schd_DedQueues);    if (schd_ExternQueues)		schd_destroy_qlist(schd_ExternQueues);    /*      * Clear queue list head pointers.  The contents of the lists have     * been destroyed, but the head still points to invalidated memory.     */    schd_SubmitQueue			= NULL;    schd_BatchQueues			= NULL;    schd_DedQueues			= NULL;    schd_SpecialQueue			= NULL;    schd_ExternQueues			= NULL;    schd_FirstRun			= 1;	/* First run since reconfig */    /*      * Reset scheduler configuration parameters     */    schd_TEST_ONLY			= 0;    schd_AVOID_FRAGS			= 1;    schd_SORT_BY_PAST_USAGE		= 1;    schd_NONPRIME_DRAIN_SYS		= 0;    schd_NP_DRAIN_BACKTIME		= 0;    schd_NP_DRAIN_IDLETIME		= 0;    schd_ENFORCE_PRIME_TIME		= 0;    schd_PRIME_TIME_START		= 0;    schd_PRIME_TIME_END			= 0;    schd_PT_SMALL_NODE_LIMIT		= 0;    schd_PT_SMALL_WALLT_LIMIT		= 0;    schd_PT_WALLT_LIMIT			= 0;    schd_WALLT_LARGE_LIMIT		= 0;    schd_WALLT_SMALL_LIMIT		= 0;    schd_SMALL_JOB_MAX			= 0;    schd_TARGET_LOAD_PCT		= 90;    schd_TARGET_LOAD_MINUS		= 15;    schd_TARGET_LOAD_PLUS		= 10;    schd_HIGH_SYSTIME			= 0;    schd_MAX_JOBS			= 0;    schd_MIN_JOBS			= 0;    schd_MAX_DEDICATED_JOBS		= 0;    schd_MAX_USER_RUN_JOBS		= 10;    schd_MAX_QUEUED_TIME		= 0;    schd_SMALL_QUEUED_TIME		= 60 * 60 * 12;    schd_INTERACTIVE_LONG_WAIT		= 0;    schd_SCHED_RESTART_ACTION		= 0;    schd_ENFORCE_ALLOCATION		= 0;    schd_ENFORCE_DEDTIME		= 0;    schd_DEDTIME_CACHE_SECS		= 0;    schd_FAKE_MACH_MULT			= 1;    schd_MANAGE_HPM			= 0;    schd_REVOKE_HPM			= 0;    schd_DECAY_FACTOR			= 0.75;    schd_OA_DECAY_FACTOR		= 0.95;    /*      * Free allocated storage for configuration commands.      */    if (schd_SERVER_HOST)		free(schd_SERVER_HOST);    if (schd_SCHED_HOST)		free(schd_SCHED_HOST);    if (schd_SCHED_ACCT_DIR)		free(schd_SCHED_ACCT_DIR);    if (schd_DEDTIME_COMMAND)		free(schd_DEDTIME_COMMAND);    if (schd_SYSTEM_NAME)		free(schd_SYSTEM_NAME);    if (schd_JOB_DUMPFILE)		free(schd_JOB_DUMPFILE);    schd_SERVER_HOST			= NULL;    schd_SCHED_HOST			= NULL;    schd_SCHED_ACCT_DIR			= NULL;    schd_DEDTIME_COMMAND		= NULL;    schd_SYSTEM_NAME			= NULL;    schd_JOB_DUMPFILE			= NULL;    /*      * Set flags indicating that allocation and usage files need to     * be loaded again.  They are updated nightly.  By doing this here,     * they will be reloaded when the config is reloaded as well.     */    schd_NeedToGetAllocInfo		= 1;    schd_NeedToGetYTDInfo		= 1;    schd_NeedToGetDecayInfo 		= 1;    /*     * Clear file change times.  NULL means "clear all files".     */    schd_forget_file(NULL);    schd_NumAllocation			= 0;    schd_clear_outage_cache();    schd_ThisHost[0] 			= '\0';    /* Get the text-strings for the scheduler commands. */    create_sched_cmdstr();}static voidcreate_sched_cmdstr(void){    static char *c_null		= "Null command";    static char *c_new		= "New job arrived";    static char *c_term		= "Job terminated";    static char *c_time		= "Periodic run";    static char *c_recyc	= "Scheduler re-cycled";    static char *c_cmd		= "Schedule request";    static char *c_config	= "Configure scheduler";    static char *c_quit		= "Exit gracefully";    static char *c_rules	= "New ruleset requested";    static char *c_first	= "Server startup, 1st run";    memset(schd_CmdStr, 0, sizeof (schd_CmdStr));    schd_CmdStr[SCH_SCHEDULE_NULL]	= c_null;    schd_CmdStr[SCH_SCHEDULE_NEW]	= c_new;    schd_CmdStr[SCH_SCHEDULE_TERM]	= c_term;    schd_CmdStr[SCH_SCHEDULE_TIME]	= c_time;    schd_CmdStr[SCH_SCHEDULE_RECYC]	= c_recyc;    schd_CmdStr[SCH_SCHEDULE_CMD]	= c_cmd;    schd_CmdStr[SCH_CONFIGURE]		= c_config;    schd_CmdStr[SCH_QUIT]		= c_quit;    schd_CmdStr[SCH_RULESET]		= c_rules;    schd_CmdStr[SCH_SCHEDULE_FIRST]	= c_first;}

⌨️ 快捷键说明

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