From 273a477a376d2cb681e5c0196b5219c18e781c1d Mon Sep 17 00:00:00 2001 From: Kizarm Date: Sat, 17 Aug 2024 20:59:36 +0200 Subject: [PATCH] lock print --- V203/hello/linux/print.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/V203/hello/linux/print.cpp b/V203/hello/linux/print.cpp index 66bba97..a97c2e1 100644 --- a/V203/hello/linux/print.cpp +++ b/V203/hello/linux/print.cpp @@ -1,16 +1,22 @@ #include +#include #include "utils.h" +static std::mutex Mutex; + void print_morse_table (const TABLE & tab) { + Mutex.lock(); int n = 0; printf("static const unsigned char compressed_table [] = {"); for (auto & e: tab) { - if ((n % 16) == 0) printf("\n"); + if ((n % 16) == 0) printf("\n "); printf("0x%02x,", e); n++; } printf("\n};\n"); + Mutex.unlock(); } void print_sinus_table (const TABLE & tab) { + Mutex.lock(); int n = 0; printf("static const uint16_t sin_tab [] = {"); for (auto & e: tab) { @@ -19,4 +25,5 @@ void print_sinus_table (const TABLE & tab) { n++; } printf("\n};\n"); + Mutex.unlock(); }