Process synchronization

Description

  • Michal Ondrejka

  • GitHub

  • may, 2022

The problem is to simulate the formation of water molecules using two kinds of threads: oxygen and hydrogen. The threads must be synchronized in a way that ensures each molecule is complete before allowing the threads to proceed.
To achieve this, a barrier must be created that prevents threads from proceeding until the required number of threads has arrived. If an oxygen thread arrives at the barrier when no hydrogen threads are present, it should wait for two hydrogen threads. If a hydrogen thread arrives at the barrier when no other threads are present, it should wait for an oxygen thread and another hydrogen thread. The solution to this problem requires implementing a synchronization mechanism that enforces the constraints of the problem.
Overall, the solution will involve creating a simulation that models the behavior of oxygen and hydrogen molecules and implementing the synchronization code to ensure that the threads are properly coordinated. Proper testing will be required to verify that the solution is correct and performs as expected.

Technology