//===================================================== file = as3_1sol.c ===== //= Simulation of booting-up multiple server with failure probability = //============================================================================= //= Notes: 1) This is assignment #1 for CIS 4930 (Simulation) = //= - This is the extra credit solution = //= 2) The theoretical solution is: = //= Percent on time = 100.0 * (1 - Pr[boot fail])^N = //= where N is the number of servers. For N = 10 and = //= Pr[boot fail] = 0.01 the answer is, 90.432% = //=---------------------------------------------------------------------------= //= Build: bcc32 as3_1sol.c, gcc -o as3_1sol as3_1sol.c = //=---------------------------------------------------------------------------= //= Execute: as3_1sol = //=---------------------------------------------------------------------------= //= History: KJC (12/16/98) - Genesis = //============================================================================= //----- Include files --------------------------------------------------------- #include // Needed for printf() #include // Needed for rand() and RAND_MAX //----- Constants ------------------------------------------------------------- #define FALSE 0 // Boolean false #define TRUE 1 // Boolean true #define NUM_DAYS 10000 // Number of days to simulate #define NUM_SERVERS 10 // Number of servers #define FAIL_PERCENT 1.0 // Percent of time a boot-up fails //----- Function prototypes --------------------------------------------------- double rand_val(void); // Generate random value between 0.0 and 1.0 //===== Main program ========================================================== void main(void) { int i, j; // Loop counters int sum_fail; // Counter for "opening late" days int fail; // Failure flag (set to TRUE or FALSE) double on_time; // Percentage of days on which mall opens on time // Initialize sum_fail to zero sum_fail = 0; // Output a "running" banner printf(">>> The simulation is running for %d days... \n", NUM_DAYS); // Run the simulation for NUM_DAYS for (i=0; i