Questions tagged [thread-synchronization]
In a multi-threaded environment thread synchronization is used to coordinate access to shared resources such as file handles, network connections, and memory
thread-synchronization
670
questions
2
votes
2
answers
125
views
How do I make an array threadsafe in Java?
I am pretty new to multithreading and want to understand it better. I want to now how to make an array threadsafe in Java? Meaning I have several threads accessing and changing the data in the array ...
0
votes
2
answers
64
views
How do I sync threads that are in the same block but doing a different operation in cuda c/c++?
I am a 4th year university student who is working on a Parallel computing course project. I have made a very bad decision in selecting the right algorithm to show case the gpu performance compared ...
0
votes
0
answers
38
views
Bit array for thread synchronization
i'm writing a concurrent implementation of the pageranking algorithm. I got some matrix market files that represent graphs, and i want to traspose the graphs from the file using a struct;
The struct ...
0
votes
0
answers
26
views
How do i use testandset() to synchronise two critical sections
I have to write two .c programs, both using the same shared memory. While one cycles from a to z, the other one has to print the same char. The task is to print the alphabet using testandset(). I'm ...
0
votes
1
answer
111
views
How to run synchronous code in Rust (one thread at a time)?
I'm building a Rest API in Rust with warp web framework and tokio async runtime, the problem is that there is a sequence of operations in my code in which the threads cannot execute them all at once, ...
0
votes
1
answer
58
views
Thread Safety Atomic Producer/Consumer
I have an app which utilizes a producer/consumer pattern for processing events (2 threads total). The main (UI) thread atomically writes to a reference-type field, and my instantiated thread ...
0
votes
1
answer
46
views
Rate Limitter created on Bucket Token Algorithm gives incorrect total requests consumes value when tested with Multiple Threads
I have created a bucket token based rate limitter in Java and tested it with a single thread and a multi thread approach using Executor Service. When I run with a single thread I get 200 as total ...
1
vote
1
answer
72
views
Why Task needs to use ManualResetEventSlim internally?
According to the source code of Task https://source.dot.net/#System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs,1483
So Task uses ManualResetEventSlim ...
0
votes
0
answers
35
views
Deadlocks in asynchronous code when using synchronization primitives
So I'm reading an older document by Stephen Cleary, and although it's old, I'd still like to understand what he meant. It's the following document (Async and Scheduled Concurrency) and in particular I'...
0
votes
0
answers
77
views
Deadlock between tbb::task_group and thread barrier
In my application i am using Intel OneAPI TBB for parallelism. I am isolating work on NUMA nodes using task_arenas. I have a couple of parallel tasks I need to execute on each NUMA node for which I am ...
0
votes
1
answer
70
views
Why using while control instead of if control in condition variables to synchronize different threads?
I have simple producer, consumer problem. While producer thread adding 10$ to global money variable, consumer thread will spend money. But there is one condition that money cannot be under 0. The ...
-2
votes
2
answers
62
views
What is causing racing condition in the buffered class
I'm trying to create a generic class to make some synchronized buffered writing operation.
I'm trying to minimize lock time, so i used a non final lock object that im my mind would be enough to keep ...
0
votes
0
answers
55
views
Thread safety for class instance access
In my application, I have the following Worker class (sample/example code):
The instance_ is accessed by WorkerThread's member thread to start/stop timer and read the file names.
class WorkerThread {
...
1
vote
1
answer
115
views
How to lock multiple critical sections in code?
I'm learning about multi-threading in C# and found out that the Mutex class, can help me to synchronize threads working. So, I want to use the ThreadPool (limited to 10 threads) and this thread's ...
0
votes
1
answer
116
views
How to synchronize this special case of threads with C++ std::thread
I need some help for following case: I have a main program that starts multiple instances of the same function as threads. The function that gets called is split in at least two parts. First, every ...