141,057 questions
0
votes
2
answers
70
views
Threading in Rust with mutable objects
I'm quite new to rust and want to do two function in parallel.
shoot(&fleet_a, &mut fleet_b)
shoot(&fleet_b, &mut fleet_a)
since they only take information from one and modify some ...
0
votes
0
answers
19
views
Actix-web + Tokio: Server hangs when using tokio::spawn with Arc<Mutex> loop
I am facing an issue where my Actix-web server starts correctly, but the moment I hit the /upload_chunk endpoint from my frontend, the request hangs forever.
After some debugging, I found that the ...
1
vote
0
answers
111
views
How is a non-parallelized for loop inside an OpenMP parallel section executed?
Consider the following code:
#pragma omp parallel
for (int run = 0; run < 10; run++)
{
std::vector<int> out;
#pragma omp for
for (int i = 0; i < 1'000'000; i++)
{
...
}
}
...
5
votes
2
answers
180
views
Is there a difference between the C# Volatile.ReadBarrier vs Volatile.Read?
In the released .NET 10 there is a new method added to the Volatile class with the name ReadBarrier().
And I don't know whether from the compilers perspective there is a difference if I do a read with ...
0
votes
1
answer
41
views
VSPackage fibers stack tracing
I am trying to display the stack traces of RTOS fibers running in a C++ solution in VS2022. Since upgrading to Windows 11 there seems to be a problem in the implementation. The existing approach, ...
1
vote
1
answer
127
views
Why does my multithreading/pointers code print random values?
My code should print the numbers given as command line arguments. Instead it prints random-looking values.
What is going on and how can I fix it?
#include <stdio.h>
#include <pthread.h>
#...
4
votes
1
answer
97
views
Java ExecutorService detect asap thread fail
I have to run x asynchronous threads , which can last several minutes each.
They ALL have to terminate properly without exceptions.
If one fails I have to stop them all immediately and not wait ...
1
vote
1
answer
193
views
How to benchmark atomic<int> vs atomic<size_t>?
I have a bounded queue with small size that definitely fit in int. So I want to use atomic<int> instead of atomic<size_t> for indexing/counter, since int is smaller it should be faster.
...
0
votes
0
answers
106
views
How efficient are pipes and threads in C compared to regular function calls or pure sequential code? [closed]
I’m currently studying Operating Systems at college, and my professor has started teaching us about threads and pipes in C.
His teaching style is very practical — he expects us not only to understand ...
0
votes
1
answer
315
views
Can external IO operations be considered as if seq_cst operations in the reasoning of multithreaded programs?
Consider this example:
// thread A:
start_transaction();
update_mysql();
commit_transaction(); // remove "key" from mysql tables
remove_redis_cache("key");
// thread B:
std::...
12
votes
1
answer
704
views
How can I set up Thread-Local Storage (TLS) callbacks on Windows without CRT?
I'm trying to register a Thread-Local Storage (TLS) callback in a Windows application without using the C runtime (CRT).
Compiler: MSVC 14.44.35207 (Visual Studio 2022)
Target: x64
OS: Windows 11
I ...
2
votes
1
answer
44
views
How to workaround slf4j reading disk on main thread in Android?
I do have the following line in my Android app:
private Logger logger = LoggerFactory.getLogger(getClass().getSimpleName());
When testing for threads access in strict mode i found the following issue ...
0
votes
2
answers
59
views
Calculate byte positions to split ndjson files into chunks
Below is the code extracted from this repo:
import os.path, io
filename = ""
n_chunks = 12 # Number of processes to use -- will split the file up into this many pieces
def ...
-1
votes
0
answers
137
views
Java Multithread EventHandling
I'm trying to write an audio player in Java/JavaFX and want to make a playlist play songs automatically. I have a button that triggers a new thread, and everything works fine so far.. but when the ...
0
votes
1
answer
86
views
Python gets stuck in an infinite loop restarting multiprocessing pool workers on error in initilization routine
I am trying to setup a multiprocessing Python task on Windows 10, Python 3.13. I have "main.py" module, containing the main entry, "orchestration.py" module with worker ...
0
votes
1
answer
162
views
Does an implementation that reorders evaluation in a single thread violate [intro.execution] p8?
[intro.execution] p8 says:
Given any two evaluations A and B, if A is sequenced before B (or, equivalently, B is sequenced after A), then the execution of A shall precede the execution of B.
...
3
votes
2
answers
163
views
Why std::atomic::store can be moved ahead of its argument's initialization in runtime?
I'm reading this: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3292r0.html
Here's code sample the question is about:
int dummy;
std::atomic<int *> ptr_to_int_1{&dummy};
std::...
0
votes
1
answer
64
views
Is data synchronization necessary on single-threaded systems?
This question stems from a technical interview where I was asking candidate about multithreading, and the differences between "true multithreading" via multiple hardware cores and/or ...
4
votes
1
answer
105
views
Understanding usage of withFileBlocking with named pipes
The following program
assumes that /path/to/mypipe is a named pipe, e.g. created via mkfifo /path/to/mypipe, with no readers/writers waiting yet,
runs two threads, of which
the main thread keeps ...
0
votes
0
answers
153
views
Is I2C device interface thread-safe on Linux?
I have a single board computer with a I2C GPIO expander device, listed as /dev/i2c-0. In my multithreaded program I open() this character device and read/write to it on separate threads using ...
0
votes
0
answers
404
views
How to enable free-threading in Python 3.14 with Python install manager?
Python has officially introduce Python install manager and free-threading feature in 3.14, but I cannot find out how to enable free-threading feature with Python install manager. Is there a way to ...
0
votes
0
answers
127
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 ...
2064
votes
35
answers
1.4m
views
What is the difference between a process and a thread?
What is the technical difference between a process and a thread?
I get the feeling a word like 'process' is overused and there are also hardware and software threads. How about light-weight processes ...
7
votes
1
answer
106
views
Can a channel's Drop omit Acquire ordering, as in the Rust Atomics and Locks book?
In Rust Atomics and Locks chapter 5 (available online for free), this example implementation of a one-time channel is presented:
pub struct Channel<T> {
pub message: UnsafeCell<...
8
votes
1
answer
252
views
Valgrind (Helgrind) is showing data race with atomic
In the following program, I want to print the output as
0102030405... so on
The 0 should be printed from one thread, odd values should be printed from second thread and even values from third thread....