Skip to main content
0 votes
0 answers
103 views

Is this protection method multithread safe?

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
-3 votes
0 answers
82 views

pthread_mutex_destroy fails with EBUSY: mutex has __count=1 but __lock=0 and __owner=0 [closed]

When attempting to destroy a mutex lock, the system encountered an inconsistent state: the lock was not held by any thread (indicated by __lock = 0and __owner = 0), but its internal reference count (...
user20629944's user avatar
-4 votes
1 answer
94 views

A global sync.Mutex don't work with multiple client packages?

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
31 views

Why use a delay time less than portMAX_DELAY when waiting for a semaphore/mutex/queue FreeRTOS?

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 ...
ajags's user avatar
  • 1
3 votes
2 answers
149 views

c++ mutex with different data in the critical section

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

Copying heap allocated memory in multiple threads... Is a mutex required or is it safe?

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
  • 631
4 votes
1 answer
143 views

c++ mutex and memory barrier

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

C++ pointers and concurrency

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
83 views

munmap shared memory with locked robust mutex makes it deadlock, why?

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
48 views

Python (with Kivy) app using buildozer crashes on Android 14/15 with pthread_mutex_lock called on a destroyed mutex in SDLActivity

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
274 views

Python mutex.cc lock issue

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 ...
ToBeOrNotToBe's user avatar
0 votes
2 answers
335 views

Sleeping Barber problem: how to prevent the barber from cutting before the customer is ready?

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
190 views

How to implement unique_lock for multiple mutexes

<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
112 views

Strange behaviour of atomicCAS when used as a mutex

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
100 views

Sequence of Events in : mutex.unlock() vs returning from a function

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

15 30 50 per page
1
2 3 4 5
322