thread-synchronization

Why is there a warp-level synchronization primitive in CUDA?

你。 提交于 2021-02-17 06:18:07
问题 I have two questions regarding __syncwarp() in CUDA: If I understand correctly, a warp in CUDA is executed in an SIMD fasion. Does that not imply that all threads in a warp are always synchronized? If so, what exactly does __syncwarp() do, and why is it necessary? Say we have a kernel launched with a block size of 1024, where the threads within a block are divided into groups of 32 threads each. Each thread communicates with other threads in it's group via shared memory, but does not

ReleaseMutex : Object synchronization method was called from an unsynchronized block of code

帅比萌擦擦* 提交于 2021-02-07 02:48:54
问题 I have this pretty straightforward piece of code that very rarely throws "System.ApplicationException : Object synchronization method was called from an unsynchronized block of code." when ReleaseMutex () is called. I logically analyzed the flow of the method and just cannot understand how/why this could happen. To my understanding, the ownership of mutex is guaranteed in this case: readonly string mutexKey; public Logger(string dbServer, string dbName) { this.mutexKey = ServiceManagerHelper

ReleaseMutex : Object synchronization method was called from an unsynchronized block of code

浪子不回头ぞ 提交于 2021-02-07 02:48:45
问题 I have this pretty straightforward piece of code that very rarely throws "System.ApplicationException : Object synchronization method was called from an unsynchronized block of code." when ReleaseMutex () is called. I logically analyzed the flow of the method and just cannot understand how/why this could happen. To my understanding, the ownership of mutex is guaranteed in this case: readonly string mutexKey; public Logger(string dbServer, string dbName) { this.mutexKey = ServiceManagerHelper

C#.NET Threading Question

▼魔方 西西 提交于 2021-02-04 19:51:07
问题 I am facing an issue with communication between threads in a C#.NET application. Hope someone will guide me in the right direction about the possible solutions. I have an application in C#.NET.It is a windows form application. My application has two threads - One thread is the main thread (UI thread) and the other one is the child thread. Lets call the child thread the "workerThread" There is only one form used in the application.Lets call this form the "MainForm" The child thread is started

Thread Synchronization for DoFn in Apache Beam

别说谁变了你拦得住时间么 提交于 2021-01-27 20:06:49
问题 I am writing a DoFn in which its instance variable elements (i.e., a shared resource) can be mutated in the @ProcessElement method: import java.util.ArrayList; import java.util.List; import org.apache.beam.sdk.transforms.DoFn; public class DemoDoFn extends DoFn<String, Void> { private final int batchSize; private transient List<String> elements; public DemoDoFn(int batchSize) { this.batchSize = batchSize; } @StartBundle public void startBundle() { elements = new ArrayList<>(); }

Is Kotlin `?.let` thread-safe?

有些话、适合烂在心里 提交于 2020-12-05 15:36:29
问题 Is Kotlin ?.let thread-safe? Let's say a variable can be changed in different thread. Is using a?.let { /* */ } thread-safe? If it's equal to if (a != null) { block() } can it happen that in if it's not null and in block it's already null? 回答1: a?.let { block() } is indeed equivalent to if (a != null) block() . This also means that if a is a mutable variable, then: a might be reassigned after the null check and hold a null value when block() is executed; All concurrency-related effects are in

Can I force a step in my dataflow pipeline to be single-threaded (and on a single machine)?

。_饼干妹妹 提交于 2020-03-26 02:23:31
问题 I have a pipeline that takes URLs for files and downloads these generating BigQuery table rows for each line apart from the header. To avoid duplicate downloads, I want to check URLs against a table of previously downloaded ones and only go ahead and store the URL if it is not already in this "history" table. For this to work I need to either store the history in a database allowing unique values or it might be easier to use BigQuery for this also, but then access to the table must be

Thread Synchronization - Synchronizing three threads to print 012012012012… not working

拈花ヽ惹草 提交于 2020-01-24 17:19:04
问题 I am trying to synchronize three threads to print 012012012012.... but it is not working correctly. Each thread is assigned a number which it prints when it receives a signal from main thread. There is something wrong with the following program which I am not able to catch. public class Application { public static void main(String[] args) { int totalThreads = 3; Thread[] threads = new Thread[totalThreads]; for (int i = 0; i < threads.length; i++) { threads[i] = new MyThread(i); threads[i]

What is the point of making the singleton instance volatile while using double lock? [duplicate]

寵の児 提交于 2020-01-09 06:01:08
问题 This question already has answers here : Why is volatile used in double checked locking (6 answers) Closed 2 years ago . private volatile static Singleton uniqueInstance In a singleton when using double lock method for synchronization why is the single instance declared as volatile ? Can I achieve the same functionality without declaring it as volatile ? 回答1: Without volatile the code doesn't work correctly with multiple threads. From Wikipedia's Double-checked locking: As of J2SE 5.0, this

understanding of Volatile.Read/Write

╄→尐↘猪︶ㄣ 提交于 2020-01-02 00:51:10
问题 I'm trying to understand the C# Volatile class. As i read: The Volatile.Write method forces the value in location to be written to at the point of the call. In addition, any earlier program-order loads and stores must occur before the call to Volatile.Write. The Volatile.Read method forces the value in location to be read from at the point of the call. In addition, any later program-order loads and stores must occur after the call to Volatile.Read. Is that means the in the case of: internal