From 659eeed131bc7fba9e55a0d6cfc70ed217a59521 Mon Sep 17 00:00:00 2001 From: lucapegolotti Date: Tue, 15 Mar 2016 09:43:49 +0100 Subject: [PATCH] Improve code readability and comments --- linearizability_tester/README.txt | 4 ++-- linearizability_tester/main.cc | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/linearizability_tester/README.txt b/linearizability_tester/README.txt index f5dc9ca..31b54b2 100755 --- a/linearizability_tester/README.txt +++ b/linearizability_tester/README.txt @@ -43,11 +43,11 @@ Data structures that support the following functions: - erase an element from the structure should be easily checkable using the Set specification contained in the src/sequential_datastructures.h file. -In general, the checker needs a sequential implementation test against the +In general, the checker needs a sequential implementation to test against the concurrent one (the EMBB one). The implementation should support efficient equality checks and efficient memory management. Stick to the implementation of the already integrated structures (stacks, queues..) for future integration. After adding the implementation of the datastructure, it is necessary to add a worker and experiment for the newly created datastructure in main.cc. Stick again to the already implemented functions (it should be sufficient to change the name of the methods that are called -on the EMBB structure). \ No newline at end of file +on the structures). \ No newline at end of file diff --git a/linearizability_tester/main.cc b/linearizability_tester/main.cc index b342b0f..ceafb33 100644 --- a/linearizability_tester/main.cc +++ b/linearizability_tester/main.cc @@ -1,10 +1,17 @@ +/* + * Main script that applies the linearizability tester on embb data structures. + */ + #include +#include #include #include #include #include +// Each thread executes quasi randomly operations (TryEqneueu, TryDequeue) +// on the concurrent data structure and construct the history. template static void embb_worker_stack( const WorkerConfiguration& worker_configuration, @@ -16,7 +23,6 @@ static void embb_worker_stack( std::uniform_int_distribution<> value_dist('\0', worker_configuration.max_value); std::uniform_int_distribution<> percentage_dist(0, 100); - // each operation returns false bool ret; char value; @@ -28,6 +34,8 @@ static void embb_worker_stack( { value = value_dist(rd); percentage = percentage_dist(rd); + // Note: this threshold affects considerably the running time of the test + // increasing threshold -> increasing running time if (percentage < 30) { call_entry_ptr = concurrent_log.push_back(state::Stack::make_try_push_call(value)); @@ -43,6 +51,8 @@ static void embb_worker_stack( } } +// Each thread executes quasi randomly operations (TryEqneueu, TryDequeue) +// on the concurrent data structure and construct the history. template static void embb_worker_queue( const WorkerConfiguration& worker_configuration, @@ -54,7 +64,6 @@ static void embb_worker_queue( std::uniform_int_distribution<> value_dist('\0', worker_configuration.max_value); std::uniform_int_distribution<> percentage_dist(0, 100); - // each operation returns false bool ret; char value; @@ -66,6 +75,8 @@ static void embb_worker_queue( { value = value_dist(rd); percentage = percentage_dist(rd); + // Note: this threshold affects considerably the running time of the test + // increasing threshold -> increasing running time if (percentage < 20) { call_entry_ptr = concurrent_log.push_back(state::Queue::make_try_enqueue_call(value)); @@ -81,6 +92,7 @@ static void embb_worker_queue( } } +// Creates the history and apply the tester on it template static void embb_experiment_stack(bool is_linearizable) { @@ -127,6 +139,7 @@ static void embb_experiment_stack(bool is_linearizable) << seconds.count() << " s " << std::endl; } +// Creates the history and apply the tester on it template static void embb_experiment_queue(bool is_linearizable) { @@ -152,7 +165,6 @@ static void embb_experiment_queue(bool is_linearizable) std::ref(concurrent_log), std::ref(concurrent_queue)); const std::size_t number_of_entries{ concurrent_log.number_of_entries() }; const LogInfo> log_info{ concurrent_log.info() }; - // std::cout << log_info << std::endl; auto start = std::chrono::system_clock::now(); auto end = std::chrono::system_clock::now(); @@ -177,7 +189,7 @@ static void embb_experiment_queue(bool is_linearizable) int main() { - // Test functions and structures in linearizability_tester.h + // Test functions and structures in linearizability_tester.h and sequential_data_structures.h run_tests(); embb::base::Thread::SetThreadsMaxCount(255); -- libgit2 0.26.0