From 22a12e2995b1c59161214d26da631af26c4ea1c1 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Mon, 25 Nov 2024 22:42:17 -0800 Subject: [PATCH] mutex: use cerr for printing debug info --- main.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.cpp b/main.cpp index d17dac0..a1e1ca0 100644 --- a/main.cpp +++ b/main.cpp @@ -6,7 +6,7 @@ #include // size_t #include // memset #include -#include // cout +#include // cerr #include // vector // used for threads @@ -50,7 +50,7 @@ void *thread_task_increment(const struct thread_data &thread) { SLEEP; - std::cout << "Hello from thread " << thread.id << "! (before run loop)" + std::cerr << "Hello from thread " << thread.id << "! (before run loop)" << std::endl; SLEEP; @@ -61,7 +61,7 @@ void *thread_task_increment(const struct thread_data &thread) { // non-mutex operations { - std::cout << "Hello from thread " << thread.id + std::cerr << "Hello from thread " << thread.id << "! (inside run loop, before mutex)" << std::endl; } @@ -83,7 +83,7 @@ void *thread_task_increment(const struct thread_data &thread) { // enter the mutex - std::cout << "Hello from thread " << thread.id + std::cerr << "Hello from thread " << thread.id << "! (inside run loop, inside mutex)" << std::endl; SLEEP; @@ -105,7 +105,7 @@ void *thread_task_increment(const struct thread_data &thread) { } } - std::cout << "Hello from thread " << thread.id << "! (done)" << std::endl; + std::cerr << "Hello from thread " << thread.id << "! (done)" << std::endl; pthread_exit(nullptr); } @@ -155,7 +155,7 @@ void do_threading(struct thread_group threads) { SLEEP; } - std::cout << "Threads have been spawned." << std::endl; + std::cerr << "Threads have been spawned." << std::endl; // loop until all threads are done for (size_t finished_threads = 0; finished_threads < threads.total_threads;) {