Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
128 views

I've written a MQTT client for embedded system with RTOS (understand not POSIX, generally FreeRTOS). There's no pthread in the system. There's only 32 bits atomic instructions supported. The client ...
xryl669's user avatar
  • 3,682
-4 votes
1 answer
121 views

I have a package "tools" that expose a method that must execute some logic only one time. The next calls don't do nothing. The file tools/tools.go is like: package tools import ( "...
Santiago Rincon's user avatar
1 vote
0 answers
51 views

First I want to make sure I'm understanding the behavior of what is happening when trying (and failing) to take a semaphore or mutex... When this code runs (assuming xSemaphoreTake is going to fail to ...
ajegs's user avatar
  • 1
3 votes
2 answers
162 views

class MyTest { void getter() { std::unique_lock lock(mutex_); if (!set_) { cout << "set already" << endl; } lock.unlock(); // question ...
SuperBald's user avatar
  • 333
3 votes
1 answer
160 views

Environment is Ubuntu 24.04, QT Creator 6, g++ 13.3, pthreads. Given the following code (error handling has been removed for readability): #include <iostream> #include <thread> #include &...
Mike's user avatar
  • 629
4 votes
1 answer
153 views

class MyTest { void getter() { std::unique_lock lock(mutex); if (!set_) { cout << "set already" << endl; ...
SuperBald's user avatar
  • 333
6 votes
2 answers
208 views

I need some help for understanding general basics of shared resource access in C++ multithreading. When I need some variable that must be accessible for several threads, I declare it as atomic, or ...
Alexander Leonov's user avatar
3 votes
1 answer
97 views

I need to use robust mutexes for IPC in case one of my processes crashes while holding a mutex locked. Definition is clear from e.g. man pthread_mutexattr_setrobust and I will not repeat it here. I ...
toxic's user avatar
  • 600
2 votes
0 answers
60 views

Title Android 14/15 crash with Kivy + Buildozer: pthread_mutex_lock called on a destroyed mutex (SDLActivity) Problem Description I'm building a Python game using Kivy, packaged for Android via ...
swatiaai's user avatar
1 vote
0 answers
361 views

I have a python program that hangs in a library call on this message: [mutex.cc : 452] RAW: Lock blocking 0x6000009e1158 @ I started the program with trace to see what is going on, and I get (a lot ...
Clovis's user avatar
  • 4,483
0 votes
2 answers
352 views

Recently, I've been studying the classic Sleeping Barber problem and came across a possible solution from Wikipedia: # The first two are mutexes (only 0 or 1 possible) Semaphore barberReady = 0 ...
CN.hitori's user avatar
2 votes
0 answers
195 views

<mutex> contains different RAII wrappers: lock_guard - single mutex, always locked unique_lock - single mutex, can defer or try scoped_lock - many mutexes, always locked, supersedes lock_guard ...
Dominik Kaszewski's user avatar
2 votes
1 answer
117 views

I'm trying to learn CUDA programming, and recently I have been working on the lectures in this course: https://people.maths.ox.ac.uk/~gilesm/cuda/lecs/lec3.pdf, where they discussed the atomicCAS ...
Dang Manh Truong's user avatar
1 vote
2 answers
109 views

short brief - I want to understand the sequence of event when returning from a function and unlocking a mutex in the same function. helper macro: to print to screen #define TRACE() {std::cout <&...
Sahil Khan's user avatar
0 votes
1 answer
72 views

I'm writing a Python application that connects to an external device. I want to enable the user to operate multiple devices simultaneously by running multiple instances of the application, but each ...
Ilya's user avatar
  • 645
4 votes
1 answer
103 views

I know that, for POSIX shared and robust mutexes, if the process holding them crashes, the next process trying to acquire the lock will successfully call pthread_mutex_lock, which will return ...
Alessandro Bertulli's user avatar
4 votes
1 answer
114 views

I know that Mutex is an invariant Rust type, so Mutex<&'a T> cannot be converted to Mutex<&'b T> even if 'a outlives 'b. In my code I want to convert Arc<Mutex<&'a mut T&...
Dmitry Gordon's user avatar
0 votes
1 answer
85 views

Since unit type () in Rust occupies 0 bytes, basically to which nothing can be written or read from. So, is synchronization really required for sharing unit types across threads using Arc and Mutex?
Harry's user avatar
  • 4,146
1 vote
0 answers
60 views

I've got some code that, for reasons not germane to the problem at hand: Must write very large log messages Must write them from multiple multiprocessing worker processes Must not interleave the logs ...
ShadowRanger's user avatar
1 vote
3 answers
136 views

Call Mutex.lock() after if let. This lock will be held inside the whole if let block. If we lock again in the if let block. It's deadlock. This also happen for RwLock. use std::sync::Mutex; fn main() {...
Yanni Wang's user avatar
0 votes
0 answers
104 views

I have been writing my own x86 32-bit operating system for the past month or so. My system uses just one core. Anyway, I have been reading a lot about memory fences, CPU optimizations, and compiler ...
c.abate's user avatar
  • 442
24 votes
6 answers
5k views

Looking in cppreference, it seems to imply a std::binary_semaphore may be more efficient than a std::mutex. Is there any reason not to use a std::binary_semaphore initialized to 1 instead of a std::...
Baruch's user avatar
  • 22k
1 vote
0 answers
51 views

(I know that this question has come up several times on Stack Overflow already, but I still think it is worth clarifying some details.) Suppose that there are two independent Python processes: a.py ...
Richard's user avatar
  • 133
4 votes
0 answers
143 views

In Rad Studio 12 C++ (Delphi/C++Builder), using VCL. I'm facing an issue in my application where the minimize button becomes don't working after restoring the main window from the system tray by a ...
user30130283's user avatar
1 vote
0 answers
184 views

I'm encountering an issue with my ESP32 project using LVGL for UI rendering. After running for about 30 minutes, the entire UI freezes. After some debugging, it seems that the freeze is due to my ...
Anvesh's user avatar
  • 11
0 votes
0 answers
51 views

I want to make sure that I have visualization in one stream and all calculations in the other, I need some changes to be visible during the calculations, for this I wanted to change the variables ...
Kasatka's user avatar
0 votes
1 answer
60 views

I'm using Kotlin coroutines to manage a TLS socket connection. In my minimal version of sendMessageToServerTest, I call connectTest() when the socket is not connected, then log the result. However, ...
A.M.'s user avatar
  • 223
0 votes
2 answers
124 views

I need to ensure only 1 instance of the application is running. So I have a Mutex lock code in the Main() method which works fine. now I have a requirement to pass a command line argument to the ...
Manali's user avatar
  • 53
0 votes
1 answer
65 views

I'm working on a homework question (end of this PDF): https://pages.cs.wisc.edu/~remzi/OSTEP/threads-bugs.pdf Code: https://github.com/remzi-arpacidusseau/ostep-homework/tree/master/threads-bugs In ...
肯安定's user avatar
1 vote
1 answer
80 views

I was expecting to trigger a AbandonedMutexException after a task that does not release the mutex, the program stuck when WaitOne after the task: Mutex mutex = new(); BankAccount account = new(); ...
jamgoo's user avatar
  • 107
2 votes
2 answers
173 views

So I have this lab problem where I need to use 2 threads with mutex and cond var to print the title pattern. The pattern is stored in an array of char, and there's a global keeping track of which ...
Sliferslacker's user avatar
1 vote
1 answer
62 views

I'm working on Philosopher. The Philosophers project involves simulating the behavior of several philosophers sitting around a table, sharing forks to eat. The aim is to implement this simulation ...
ambroiselebs's user avatar
2 votes
1 answer
133 views

I've read that using a mutex in a signal handler can cause deadlock if a thread of the main program has locked the mutex before the signal handler is invoked. I've also read suggestions that signal ...
textral's user avatar
  • 1,101
1 vote
0 answers
82 views

I have a queue of worker thread IDs in C++, and a coordinator thread wakes each thread in order. The woken thread then interacts with the coordinator thread to perform some work. Once done, the ...
Utkarsh Munjal's user avatar
6 votes
4 answers
229 views

I need to get a lock only during evaluation of the if statement condition. The lock must be released when running the code inside the if or else statements. I found a piece of code and I don't know if ...
Stefan's user avatar
  • 1,367
0 votes
1 answer
80 views

I am creating a program that consists of WebsocketReader, which reads data from a websocket (basically runs a loop to read out the newly incoming data), and ConfigurationFetcher, which needs to ...
Lukáš Řádek's user avatar
1 vote
0 answers
97 views

I am trying to set up SIGINT signal handler to wake up the main thread via binary semaphore. For that, as I attach below, I set up a SIGINT handler to run handler() function which just increments ...
Stepan .Kuznetsov's user avatar
0 votes
2 answers
205 views

Why can't I declare an optional std::lock_guard and then assign it later? The same thing with an optional string works just fine. This works: std::mutex m; std::optional<std::lock_guard<std::...
H.v.M.'s user avatar
  • 1,746
2 votes
1 answer
96 views

This program hangs and I suspect it does not release the mutex lock as it is supposed to. I must be doing something wrong here, but I cannot put my finger on it. use std::any::TypeId; use std::...
hkBst's user avatar
  • 3,430
1 vote
1 answer
49 views

There is such an interesting little code (I'll take the most important thing, since my project is quite large void RunForever(int time_out) { int criticalSize = 3; ...
user29207775's user avatar
-1 votes
1 answer
97 views

I need a global mutex to ensure only one instance of my application can run at a time. I found the following code on SO: using var mutex = MutexAcl.Create(true, mutexId, out bool mutexCreated, ...
user107586's user avatar
2 votes
1 answer
132 views

I think the source code below may not end forever. Assume that all waiter threads have entered the wait state. After that, waker call notify_all() One thread, t1, wakes up and does something. And ...
user19800684's user avatar
-3 votes
2 answers
147 views

Immediately after spawning a thread with pthread_create, I would like the parent to wait an arbitrary amount of time until the child thread allows it to continue. Here is how I might approach it with ...
Adam Rutledge's user avatar
0 votes
1 answer
67 views

I am confused by the results of running the following code. I can understand the logic of the behavior, but it seems a bit unreasonable to me (because I think it makes the variable lifetime confusing) ...
Nullptr's user avatar
  • 19
2 votes
1 answer
76 views

I have a "single application instance" detection function, using the "classic" Mutex approach: var identity = new SecurityIdentifier(WellKnownSidType.WorldSid, null); var ...
Adam Calvet Bohl's user avatar
0 votes
1 answer
70 views

I am trying to make a plugin for OBS Studio that will add a custom source type object. OBS provide a simple way to let the user display and change the source properties with the function ...
Bukibarak's user avatar
0 votes
1 answer
119 views

Kotlin document states that Mutex is for synchronizing co-routines, not System-level threads: The key difference is that Mutex.lock() is a suspending function. It does NOT block a thread. - kotlin ...
user7858768's user avatar
  • 1,086
-2 votes
2 answers
208 views

I'm trying to figure out the scope of mutexes and mutex lock_guard and no one has been able to explain it to me. Consider the following c++ code: void somefunction { std::lock_guard<std::mutex&...
Matt123's user avatar
  • 411
0 votes
1 answer
124 views

I'm trying to understand c++ semaphore and mutex, and I found out that I'm locking 1 mutex several times, or at least my debugging messages are showing that is the case. Even though we have only 1 ...
Daniel Dobiński's user avatar
2 votes
1 answer
63 views

Goal Implement a MPSC-like queue with mutexes and sempahores. Issue Eventually, the consumer will attempt to dequeue an empty queue. Minimal Reproducible Example I have edited the question to include ...
Kungfunk's user avatar
  • 115

1
2 3 4 5
97