From 02c12c42564830f364a0c0e74271f35a80184089 Mon Sep 17 00:00:00 2001 From: Geoffrey Challen Date: Thu, 18 Feb 2016 16:36:11 -0500 Subject: [PATCH] Change to the synchronization problem drivers. --- kern/test/synchprobs.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/kern/test/synchprobs.c b/kern/test/synchprobs.c index 42814e8..275280e 100644 --- a/kern/test/synchprobs.c +++ b/kern/test/synchprobs.c @@ -80,6 +80,8 @@ static volatile int female_end_count; static volatile int matchmaker_start_count; static volatile int matchmaker_end_count; static volatile int match_count; +static volatile int concurrent_matchmakers; +static volatile int max_concurrent_matchmakers; static volatile void* whale_threads[3 * NMATING]; static volatile int whale_roles[3 * NMATING]; @@ -203,6 +205,10 @@ matchmaker_start(uint32_t index) { check_thread(whale_threads, index); check_role(index, MATCHMAKER); matchmaker_start_count++; + concurrent_matchmakers++; + if (concurrent_matchmakers > max_concurrent_matchmakers) { + max_concurrent_matchmakers = concurrent_matchmakers; + } kprintf_n("%s starting\n", curthread->t_name); kprintf_t("."); lock_release(testlock); @@ -216,9 +222,9 @@ matchmaker_end(uint32_t index) { lock_acquire(testlock); check_thread(whale_threads, index); check_role(index, MATCHMAKER); - match_count++; matchmaker_end_count++; + concurrent_matchmakers--; kprintf_n("%s ending\n", curthread->t_name); kprintf_t("."); lock_release(testlock); @@ -244,6 +250,8 @@ whalemating(int nargs, char **args) { matchmaker_start_count = 0; matchmaker_end_count = 0; match_count = 0; + concurrent_matchmakers = 0; + max_concurrent_matchmakers = 0; kprintf_n("Starting sp1...\n"); kprintf_n("If this tests hangs, your solution is incorrect.\n"); @@ -288,7 +296,7 @@ whalemating(int nargs, char **args) { } total_count += 1; if (err) { - panic("whalemating: thread_fork failed: (%s)\n", strerror(err)); + panic("sp1: thread_fork failed: (%s)\n", strerror(err)); } } } @@ -323,7 +331,7 @@ whalemating(int nargs, char **args) { snprintf(name, sizeof(name), "Matchmaker Whale Thread %d", index); err = thread_fork(name, NULL, matchmaker_wrapper, NULL, index); if (err) { - panic("whalemating: thread_fork failed: (%s)\n", strerror(err)); + panic("sp1: thread_fork failed: (%s)\n", strerror(err)); } total_count++; } @@ -376,6 +384,8 @@ whalemating(int nargs, char **args) { } } + failif((max_concurrent_matchmakers == 1), "failed: no matchmaker concurrency"); + whalemating_cleanup(); done: @@ -645,7 +655,7 @@ int stoplight(int nargs, char **args) { break; } if (err) { - panic("stoplight: thread_fork failed: (%s)\n", strerror(err)); + panic("sp2: thread_fork failed: (%s)\n", strerror(err)); } }