Questions tagged [barrier]

A barrier is a synchronization method for a group of threads or processes and means they must stop at this point and cannot proceed until all other threads/processes reach this barrier.

A barrier is a synchronization method for a group of threads or processes and means they must stop at this point and cannot proceed until all other threads/processes reach this barrier.

References

252 questions
3
votes
2 answers

pthread_barrier_wait hangs after creation of all threads

I'm trying to write a simple program to use a barrier to wait for the creation of several threads before printing a message from the main. Here's my code: #include #include #include #include #include…
erip
  • 16,374
  • 11
  • 66
  • 121
3
votes
1 answer

How to implement barrier using posix semaphores?

How to implement barrier using posix semaphores? void my_barrier_init(int a){ int i; bar.number = a; bar.counter = 0; bar.arr = (sem_t*) malloc(sizeof(sem_t)*bar.number); bar.cont = (sem_t*) malloc(sizeof(sem_t)*bar.number); …
diana-pure
  • 161
  • 3
  • 16
3
votes
1 answer

Reusable Barrier solution has a deadlock?

I have been reading "The Little Book of Semaphores" and in page 41 there is a solution for the Reusable Barrier problem. The problem I have is why it won't generate a deadlock situation. 1 # rendezvous 2 3 mutex.wait() 4 count += 1 5 if…
kasper360
  • 367
  • 2
  • 4
  • 14
2
votes
2 answers

Does MPI_Type_commit implicitly call a barrier on all the processes in MPI_COMM_WORLD?

In my code I define a new MPI user-defined data type. I was wondering if the MPI_Barrier function must follow the MPI_Commit or must be placed at some point where the first use of the new data type appears so that all the processes acknowledge and…
cpp_noname
  • 2,031
  • 3
  • 17
  • 30
2
votes
1 answer

how to handle barriers with threads quitting

Pseudo code: void * thread_start(void *arg) { while (1) { /* for each column. Only run columns the thread_num is assigned to */ column_count = thread_num; for (; column_count < dim - 1; column_count+=threads)…
Raynos
  • 166,823
  • 56
  • 351
  • 396
2
votes
3 answers

Race condition with MPI

I am trying to implement Tournament barrier using MPI. Here, is the code I have written. I am writing only the arrival phase and wake up phase //Arrival phase while(1) { …
CuriousCoder
  • 1,582
  • 5
  • 28
  • 55
2
votes
1 answer

Why C++ has introduced separate std::latch and std::barrier?

There are some similar questions on SO. But they only ask the question one way. std::latch has an advantage over std::barrier that unlike latter, former can be decremented by a participating thread more than once. std::barrier has an advantage over…
Sourav Kannantha B
  • 2,860
  • 1
  • 11
  • 35
2
votes
1 answer

Does NDIS spinlock serves as a memory barrier for DMA?

In an NDIS driver I need to write some data to a shared memory and then notify the HW to fetch this data. Writing to the shared memory is protected by an NDIS spinlock. There is a possible race between writing to the shared memory and notifying the…
Rony Ross
  • 21
  • 1
2
votes
1 answer

Adding barriers programmatically via ConstraintSet doesn't work when I change id's of elements?

I've been trying to add a barrier programmatically to a constraint layout in Android Studio using ConstraintSet but I just can't get my code to work, the end result should just be a textView, then a barrier to its right, and another textview that…
2
votes
2 answers

How to properly synchronize threads at barriers

I am encountering an issue where I have a hard time telling which synchronization primitive I should use. I am creating n parallel threads that work on a region of memory, each is assigned to a specific part of this region and can accomplish its…
Pop Flamingo
  • 3,023
  • 2
  • 26
  • 64
2
votes
1 answer

MPI_Barrier not working inside a loop

I have running some tests on the MPI functions to understand how it works and have got a weird result with the MPI_Barrier: it does what everyone would expect if I use it in code like int main(int argc, char *argv[]) {
josh
  • 21
  • 2
2
votes
2 answers

Using protected entry argument in barrier condition

I have a protected Hashed_Map with Vectors of data. To get an element from a specific Vector, I need to pass its key to the entry and, if the Vector is empty, wait for new elements to appear in it. In the barrier condition, the key argument is not…
2
votes
1 answer

Initializing a std::barrier with a class member function

How do you initialize a std::barrier with a class member function? class CMyClass { private: void func() { } public: void start() { } } void CMyClass::start() { std::barrier barrier(threads_count, &func()); // ?? }
Zhihar
  • 1,306
  • 1
  • 22
  • 45
2
votes
1 answer

How to print something from processes without other processes overlapping it?

I have written an MPI code which I am running using 16 processes and I am printing 4x4 matrix as output from each of those process: printf("\n This is the output of %d\n",myrank); for(int i=0;i
user15029962
2
votes
1 answer

Barrier in MPI: How to implement barrier to make processes wait for one another

Is there any way to add a barrier in MPI code. By barrier I mean, I want all the different processors to first finish till a point and then carry on from there. That is a processor must wait for the other processors to finish the code till that…
user15029962