diff options
-rw-r--r-- | bin/rtspin.beta.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/bin/rtspin.beta.c b/bin/rtspin.beta.c index 4c8a56f..556660e 100644 --- a/bin/rtspin.beta.c +++ b/bin/rtspin.beta.c | |||
@@ -36,13 +36,16 @@ static int num[NUMS]; | |||
36 | static char* progname; | 36 | static char* progname; |
37 | 37 | ||
38 | static gsl_rng *beta_rng; | 38 | static gsl_rng *beta_rng; |
39 | static gsl_rng *coin_rng; | ||
39 | 40 | ||
40 | static void setup_rng(unsigned long seed) | 41 | static void setup_rng(unsigned long seed) |
41 | { | 42 | { |
42 | beta_rng = gsl_rng_alloc(gsl_rng_taus); | 43 | beta_rng = gsl_rng_alloc(gsl_rng_taus); |
43 | if (!beta_rng) | 44 | coin_rng = gsl_rng_alloc(gsl_rng_taus); |
45 | if (!beta_rng || !coin_rng) | ||
44 | bail_out("Could not initialize RNG"); | 46 | bail_out("Could not initialize RNG"); |
45 | gsl_rng_set(beta_rng, seed); | 47 | gsl_rng_set(beta_rng, seed); |
48 | gsl_rng_set(coin_rng, seed); | ||
46 | } | 49 | } |
47 | 50 | ||
48 | static int loop_once(void) | 51 | static int loop_once(void) |
@@ -122,6 +125,8 @@ enum crit_level str2crit(const char* str) | |||
122 | 125 | ||
123 | #define OPTSTR "a:b:d:p:c:wlves:r:i:" | 126 | #define OPTSTR "a:b:d:p:c:wlves:r:i:" |
124 | 127 | ||
128 | #define COIN_PROB 0.5 | ||
129 | |||
125 | int main(int argc, char** argv) | 130 | int main(int argc, char** argv) |
126 | { | 131 | { |
127 | int ret; | 132 | int ret; |
@@ -257,8 +262,12 @@ int main(int argc, char** argv) | |||
257 | start = wctime(); | 262 | start = wctime(); |
258 | 263 | ||
259 | do { | 264 | do { |
260 | beta_sample = gsl_ran_beta(beta_rng, alpha, beta); | 265 | double coin_flip = gsl_rng_uniform(coin_rng); |
261 | exec_time = lvl_c_time * 20.0 * beta_sample * scale; | 266 | if (coin_flip < COIN_PROB) { |
267 | beta_sample = gsl_ran_beta(beta_rng, alpha, beta); | ||
268 | exec_time = lvl_c_time * 20.0 * beta_sample * scale; | ||
269 | } else | ||
270 | exec_time = lvl_c_time; | ||
262 | /* convert to seconds */ | 271 | /* convert to seconds */ |
263 | exec_time = exec_time * 0.000000001; | 272 | exec_time = exec_time * 0.000000001; |
264 | } while(job(exec_time, start + duration)); | 273 | } while(job(exec_time, start + duration)); |
@@ -268,6 +277,7 @@ int main(int argc, char** argv) | |||
268 | bail_out("could not become regular task (huh?)"); | 277 | bail_out("could not become regular task (huh?)"); |
269 | 278 | ||
270 | gsl_rng_free(beta_rng); | 279 | gsl_rng_free(beta_rng); |
280 | gsl_rng_free(coin_rng); | ||
271 | 281 | ||
272 | return 0; | 282 | return 0; |
273 | } | 283 | } |