$ $ type work_rec.c /****************************************************************/ /* Program: work_rec.c */ /* Author: Bruce Ellis, The VASTEK Company, Incorporated */ /* Function: */ /* Calculates recommended working set list sizes */ /* Based on configuration and displays them and/or */ /* creates symbols with the values. */ /* Date written: 1/8/93 */ /* Associated Files: */ /* work_rec.cld */ /* Requirements: Must include the command definition, */ /* using: $SET COMMAND WORK_REC */ /* Available commands: */ /* $WORK_RECOMMENDATIONS ! Defaults to /DISPLAY */ /* $WORK_RECOMMENDATIONS /SYMBOL !Generate display and */ /* ! symbols. */ /* $WORK_RECOMMENDATIONS /SYMBOL/NODISPLAY !Just generate */ /* ! symbols */ /****************************************************************/ /* Include files. */ #include #include #include #include /* Define a warning message for invalid time. */ #define MY_IVTIME SS$_IVTIME & ~ 0x06 #define PRESENT 1 #define SUCCESS 1 /* Define constants. */ #define HR_PER_DAY 24 #define MIN_PER_HR 60 #define SEC_PER_MIN 60 #define REC_EXT_FACTOR 2 #define MAX_EXT_FACTOR 3 /* May want to increase this on systems with large memory and variable workloads. */ #define REASONABLE_UP_DAYS 2 #define RESERVE_MEM .1 /********************************/ /* Main function. */ /********************************/ int main(void) { /* Set up descriptors for command qualifiers. */ $DESCRIPTOR(sym_qual,"SYMBOL"); $DESCRIPTOR(disp_qual,"DISPLAY"); /* Set up references for system memory locations. */ globalref int PMS$GL_PROCCNTMAX; /* Max concurrent processes since last boot. */ globalref int PFN$GL_PHYPGCNT; /* Non-VMS memory size. */ globalref int EXE$GL_ABSTIM; /* System up time in seconds.*/ /* Declare supporting functions. */ int generate_symbols(int, int, unsigned int); int display_info(int, int, unsigned int); /* Return status value, assume success. */ int ret_val = SS$_NORMAL; /* If /SYMBOL qualifier is present generate symbols. */ if(CLI$PRESENT(&sym_qual)&PRESENT) { ret_val = generate_symbols(PMS$GL_PROCCNTMAX, PFN$GL_PHYPGCNT, EXE$GL_ABSTIM); } /* If /DISPLAY qualifier is present or defaulted display information. */ if(CLI$PRESENT(&disp_qual)&PRESENT) { ret_val = display_info(PMS$GL_PROCCNTMAX, PFN$GL_PHYPGCNT, EXE$GL_ABSTIM); } /* If not up long enough, say so. */ if(!(ret_val&SUCCESS)) { fprintf(stderr,"\n***************************************\n"); fprintf(stderr,"Warning the system has been up less than %d days.\n", REASONABLE_UP_DAYS); fprintf(stderr,"The recommendations displayed here may not be"); fprintf(stderr, " valid due to short up time.\n"); fprintf(stderr,"\n***************************************\n"); } /* Sayonara. */ return(ret_val); } /* Constant for symbol max size. */ #define SYM_MAX 255 /****************************************************************/ /* Function: generate_symbols() */ /* Description: generates symbols, WSDEFAULT, WSQUOTA, */ /* WSEXTENT, and WSEXTENT_MAX based on */ /* system configuration and workload. */ /* Inputs: max_proc - Maximum number of concurrent */ /* since last boot. */ /* avail_mem - Non-VMS memory. */ /* up_time - Up time in seconds. */ /* Returns: SS$_NORMAL on success */ /* MY_IVTIME if up time less than 2 days. */ /****************************************************************/ int generate_symbols(int max_proc, int avail_mem, unsigned int up_time) { /* Set up symbol descriptors. */ $DESCRIPTOR(wsd_s,"WSDEFAULT"); $DESCRIPTOR(wsq_s,"WSQUOTA"); $DESCRIPTOR(wse_s,"WSEXTENT"); $DESCRIPTOR(wse_m_s,"WSEXTENT_MAX"); int ret_val = SS$_NORMAL; /* Return status, assume success. */ int call_stat; /* Return status for system function calls. */ int up_days; /* Up time in days. */ /* Strings containing equivalence values. */ char wsd[SYM_MAX]; char wsq[SYM_MAX]; char wse[SYM_MAX]; char wse_m[SYM_MAX]; /* Set up equivalence name descriptors. */ struct dsc$descriptor_s wsd_sym = {SYM_MAX,DSC$K_DTYPE_T, DSC$K_CLASS_S, wsd}, wsq_sym = {SYM_MAX,DSC$K_DTYPE_T, DSC$K_CLASS_S, wsq}, wse_sym = {SYM_MAX,DSC$K_DTYPE_T, DSC$K_CLASS_S, wse}, wse_max = {SYM_MAX,DSC$K_DTYPE_T, DSC$K_CLASS_S, wse_m} ; /* Calculate up time. */ up_days = up_time / (HR_PER_DAY * MIN_PER_HR * SEC_PER_MIN); /* Set up warning if system has not been up long enough. *./ if(up_days < REASONABLE_UP_DAYS) { ret_val = MY_IVTIME; } /* Compute recommended WSDEFAULT, WSQUOTA, WSEXTENT, and WSEXTENT_MAX */ /* and create equivalence strings. */ sprintf(wsd, "%d", (avail_mem - (int)(avail_mem * RESERVE_MEM))/ (max_proc)); wsd_sym.dsc$w_length = strlen(wsd); sprintf(wsq, "%d", (avail_mem - (int)(avail_mem * RESERVE_MEM))/ (max_proc)); wsq_sym.dsc$w_length = strlen(wsq); sprintf(wse, "%d", (avail_mem - (int)(avail_mem * RESERVE_MEM))/ (max_proc) * REC_EXT_FACTOR); wse_sym.dsc$w_length = strlen(wse); sprintf(wse_m, "%d", (avail_mem - (int)(avail_mem * RESERVE_MEM))/ (max_proc) * MAX_EXT_FACTOR); wse_max.dsc$w_length = strlen(wse_m); /* Create symbols for WSDEFAULT, WWSQUOTA, WSEXTENT, and WSEXTENT_MAX.*/ call_stat = LIB$SET_SYMBOL(&wsd_s, &wsd_sym); if(!(call_stat&SUCCESS)) LIB$SIGNAL(call_stat); call_stat = LIB$SET_SYMBOL(&wsq_s, &wsq_sym); if(!(call_stat&SUCCESS)) LIB$SIGNAL(call_stat); call_stat = LIB$SET_SYMBOL(&wse_s, &wse_sym); if(!(call_stat&SUCCESS)) LIB$SIGNAL(call_stat); call_stat = LIB$SET_SYMBOL(&wse_m_s, &wse_max); if(!(call_stat&SUCCESS)) LIB$SIGNAL(call_stat); /* Beat it. */ return(ret_val); } /****************************************************************/ /* Function: display_info() */ /* Description: generates a display containing: */ /* system uptime, max concurrent process */ /* since last boot, Non-VMS memory, and */ /* recommended values for: */ /* WSDEFAULT, WSQUOTA, */ /* WSEXTENT, and WSEXTENT_MAX based on */ /* system configuration and workload. */ /* Inputs: max_proc - Maximum number of concurrent */ /* since last boot. */ /* avail_mem - Non-VMS memory. */ /* up_time - Up time in seconds. */ /* Returns: SS$_NORMAL on success */ /* MY_IVTIME if up time less than 2 days. */ /****************************************************************/ int display_info(int max_proc, int avail_mem, unsigned int up_time) { /* Calculated recommendations. */ int wsd_val; int wsq_val; int wse_val; int wse_m_val; /* Time variables. */ int up_days; int up_hours; int up_min; int rem_time; /* Return value, assume success. */ int ret_val= SS$_NORMAL; /* Calculate recommended WSDEFAULT and WSQUOTA. */ wsd_val = wsq_val = (avail_mem - (int)(avail_mem * RESERVE_MEM))/ max_proc; /* Calculate recommended WSEXTENT and maximum rec. WSEXTENT. */ wse_val = wsq_val * REC_EXT_FACTOR; wse_m_val = wsq_val * MAX_EXT_FACTOR; /* Breakdoen up time into days, hours, and minutes. */ up_days = up_time / (HR_PER_DAY * MIN_PER_HR * SEC_PER_MIN); rem_time = up_time % (HR_PER_DAY * MIN_PER_HR * SEC_PER_MIN); up_hours = rem_time / (MIN_PER_HR * SEC_PER_MIN); rem_time = rem_time % (MIN_PER_HR * SEC_PER_MIN); up_min = rem_time / SEC_PER_MIN; /* If not up long enough, set warning. */ if(up_days < REASONABLE_UP_DAYS) { ret_val = MY_IVTIME; } /* Display info. */ printf("The system has been up for %4d %02d:%02d\n", up_days, up_hours, up_min); printf("There are %d pages of available memory.\n", avail_mem); printf("The maximum number of concurrent processes since last boot"); printf(" is %d\n", max_proc); printf("The recommended working set list sizes are:\n"); printf("WSDEFAULT = %d\n", wsd_val); printf("WSQUOTA = %d\n", wsq_val); printf("WSEXTENT = %d\n", wse_val); printf("The maximum recommended WSEXTENT is %d.\n", wse_m_val); /* Beat it! */ return(ret_val); } $ $ $ type my_opt.opt sys$share:vaxcrtl/share $ $ cc work_rec $ link work_rec,my_opt/opt, sys$system:sys.stb $ $ $ type work_rec.cld define verb work_recommendations ! Use appropriate full file specification for program here image USER5:[ELLISB]work_rec qualifier symbol, negatable qualifier display, default, negatable $ $ $ $ set command work_rec $ $ $ work_reccommendations The system has been up for 4 11:12 There are 342943 pages of available memory. The maximum number of concurrent processes since last boot is 286 The recommended working set list sizes are: WSDEFAULT = 1079 WSQUOTA = 1079 WSEXTENT = 2158 The maximum recommended WSEXTENT is 3237. $ $ $ show symbol/local/all $ $ work/NODISPLAY/SYMBOL $ $ $ show symbol/local/all WSDEFAULT = "1079" WSEXTENT = "2158" WSEXTENT_MAX = "3237" WSQUOTA = "1079" $ $ show memory/physical System Memory Resources on 9-JAN-1993 18:07:14.76 Physical Memory Usage (pages): Total Free In Use Modified Main Memory (192.00Mb) 393216 227852 154917 10447 Of the physical pages in use, 50273 pages are permanently allocated to VMS. $ $ $