| 360 | } |
| 361 | |
| 362 | static void flashProb_parse_params(cache_t *cache, |
| 363 | const char *cache_specific_params) { |
| 364 | flashProb_params_t *params = (flashProb_params_t *)(cache->eviction_params); |
| 365 | |
| 366 | char *params_str = strdup(cache_specific_params); |
| 367 | char *old_params_str = params_str; |
| 368 | |
| 369 | while (params_str != NULL && params_str[0] != '\0') { |
| 370 | /* different parameters are separated by comma, |
| 371 | * key and value are separated by = */ |
| 372 | char *key = strsep((char **)¶ms_str, "="); |
| 373 | char *value = strsep((char **)¶ms_str, ","); |
| 374 | |
| 375 | // skip the white space |
| 376 | while (params_str != NULL && *params_str == ' ') { |
| 377 | params_str++; |
| 378 | } |
| 379 | |
| 380 | if (strcasecmp(key, "ram-size-ratio") == 0) { |
| 381 | params->ram_size_ratio = strtod(value, NULL); |
| 382 | } else if (strcasecmp(key, "disk-admit-prob") == 0) { |
| 383 | params->disk_admit_prob = strtod(value, NULL); |
| 384 | params->inv_prob = (int) (1.0 / params->disk_admit_prob); |
| 385 | } else if (strcasecmp(key, "ram-cache") == 0) { |
| 386 | strncpy(params->ram_cache_type, value, 15); |
| 387 | } else if (strcasecmp(key, "disk-cache") == 0) { |
| 388 | strncpy(params->disk_cache_type, value, 15); |
| 389 | } else if (strcasecmp(key, "print") == 0) { |
| 390 | printf("parameters: %s\n", flashProb_current_params(params)); |
| 391 | exit(0); |
| 392 | } else { |
| 393 | ERROR("%s does not have parameter %s\n", cache->cache_name, key); |
| 394 | exit(1); |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | free(old_params_str); |
| 399 | } |
| 400 | |
| 401 | #ifdef __cplusplus |
| 402 | } |
no test coverage detected