parallele-programmierung/u06-1
Luca Conte 636efbe8b3 add assignment readmes 2025-05-07 21:06:08 +02:00
..
Barrier.java remove package 2025-04-23 23:17:21 +02:00
BarrierTest.java remove package 2025-04-23 23:17:21 +02:00
Concurrent.java remove package 2025-04-23 23:17:21 +02:00
README.md add assignment readmes 2025-05-07 21:06:08 +02:00

README.md

Problem 6.1: Barrier without semaphore

Implement a class Barrier that realizes a barrier similar to the CyclicBarrier mentioned on slide 4-50 (your barrier does not have to be reusable); barriers are also described in the book by Gleim/Schüle in section 3.2.7 (in German). Don't use semaphores, but only synchronized, wait() and notify/All(). Your class should look about as follows:

class Barrier {
	// …
	public Barrier(int nThreads){  }
		// nThreads: Number of threads using this barrier
	public int await() throws InterruptedException {  }
		// Cross the barrier, possibly waiting before doing this
		// Return value: Position of this thread when arriving at the barrier
}

Test your barrier with class BarrierTest in the source code folder on th server. In the program's output, all a() invocations must appear before all b() invocations Barrier if your barrier is correct.