Skip to content

Commit

Permalink
Reimplements the "Temporary Fail & Recover" policy
Browse files Browse the repository at this point in the history
  • Loading branch information
alobbs committed Jun 30, 2014
1 parent 80ef1e9 commit 7e18f9a
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions libchula/test/OOM/oom.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ exec_sched_fail (int (*test)(void))
chula_mem_policy_counter_mrproper (&policy_c);

/* Execute: Fail after N */
PRINT ("Permanent Fail:\n");
for (uint32_t n=0; n<=total_calls; n++) {
PRINT ("\t% 3d of % 3d: ", n, total_calls);
chula_mem_policy_sched_fail_init (&policy_f, n, INT_MAX);
Expand All @@ -61,12 +62,23 @@ exec_sched_fail (int (*test)(void))
chula_mem_mgr_reset (&mgr);

/* Execute: Fail and recover after N */
uint32_t total = 0;
uint32_t current = 1;

PRINT ("Temporary Fail & Recover:\n");

for (uint32_t n=0; n<=total_calls; n++)
for (uint32_t l=1; l<=total_calls-n; l++)
total++;

for (uint32_t n=0; n<=total_calls; n++) {
PRINT ("\t% 3d of % 3d: ", n, total_calls);
chula_mem_policy_sched_fail_init (&policy_f, n, 1);
chula_mem_mgr_set_policy (&mgr, MEM_POLICY(&policy_f));
re += test();
PRINT ("\n");
for (uint32_t l=1; l<=total_calls-n; l++) {
PRINT ("\t% 3d of % 3d: ", current++, total);
chula_mem_policy_sched_fail_init (&policy_f, n, l);
chula_mem_mgr_set_policy (&mgr, MEM_POLICY(&policy_f));
re += test();
PRINT ("\n");
}
}

/* Clean up */
Expand Down

0 comments on commit 7e18f9a

Please sign in to comment.