141,057 questions
0
votes
2
answers
67
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 ...
-6
votes
0
answers
71
views
Undesired Pulsating in Rendering and Cumulative Slowdown When Implementing Fixed Physics Timestep in Multithreaded Physics [closed]
INTRO
I am getting unwanted pulsing and slowing down in rendering 2d particles, which should be drawn faintly (low alpha) and leave a fading trail under the influence of gravity. Below is a ...
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++)
{
...
}
}
...
Best practices
0
votes
3
replies
64
views
Is there anyway to get physical disk Idle time without 1 second wait needed for PerformanceCounter.NextValue function?
I trying to develop user-friendly program that do not block physical disk with 100% usage (so even entering My Computer takes around 10 seconds).
My program calculate hash for many (180k) small files ...
0
votes
2
answers
120
views
compare_exchange_strong failed to update the expected value
I am trying to implement a lock-free multiple-producer-single-consumer ring buffer in C++. Here is the full definition and the test code.
#include <iostream>
#include <memory>
#include <...
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 ...
1
vote
0
answers
62
views
C# Multithreading Issue with Simultaneous Smart Card Printing on Multiple Evolis Primacy 2 Printers
I'm developing a C# application that needs to handle simultaneous printing on 4 Evolis Primacy 2 printers with Elyctis encoders. Each printer must write to card chips and print on cards completely ...
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 ...
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.
...
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
1
answer
76
views
Pyspark- Multithreading in Python
I have a user case like this. I have a list of many queries. I am running multi-threading with pyspark with each thread submitting some sql.
There are some queries that report success but the final ...
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 ...
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 ...
2
votes
2
answers
191
views
Is it possible/how to let parent class thread invoke function in child class that overrides parent function?
I am trying to implement a Parent and Child class. The Parent class would start a thread and run a routine function. The Child class would override the routine function if needed.This seems perfectly ...
0
votes
0
answers
38
views
How to achieve complete read/write thread separation for BoringSSL using BIO APIs
I'm integrating BoringSSL into my networking library for secure communication. I've observed that both SSL_read() and SSL_write() operations can potentially trigger both read and write activities on ...
0
votes
0
answers
147
views
Do the RMW operations on `cnt` still not avoid an inconsistent status for this multiple-producer single-consumer implementation?
Looking at this implementation of multiple-producer single-consumer, which was the implementation in Rust's standard library; however, its memory order model is derived from C++. So, it should be ...
2
votes
2
answers
165
views
Java Thread interrupt non deterministic behaviour
I have this piece of code in Java and I tried it out on Java 21 (Eclipse Temurin and GraalVM)
public static void main(String[] args) {
Thread.currentThread().interrupt();
long start = ...
1
vote
1
answer
131
views
is jax really incompatible with python multiprocesses? [closed]
I have a simple app with a main controller process, and a child process that handles API calls. They communicate using Python queues.
The app looks (something) like this:
import multiprocessing as mp
...
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
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 ...
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 ...
3
votes
1
answer
141
views
Even after clicking on the terminal screen, it doesn't print "Left pressed", how do i fix this?
I want it to print that whenever you click on the terminal screen.
I'm using win32 API in C programming btw, and here is the full code below:
#include <stdio.h>
#include <windows.h>
#...
4
votes
1
answer
210
views
How do I interrupt a pybind11 exec call?
I am trying to make an application using python code and C++, but I need some kind of protection against infinite loops or too long executions. I tried following some threads and seeing how other ...
2
votes
0
answers
87
views
Python app multithread with pyQT5 delivered as .exe using pyinstaller is crashing after 40-50 minutes
I am developing a multithread application using the library pyQt5. There are many threads activated in order to plot in the GUI some data extracted from many devices (one thread <-> one device). ...
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<...