Question: Task 3 : Synchronisation with semaphores ( 4 0 marks ) There are two explorer, three miner and three transporter machines have been deployed to

Task 3: Synchronisation with semaphores (40 marks)
There are two explorer, three miner and three transporter machines have been deployed to a field
to search, extract and transport specific materials. Each explorer will detect the existence of the
specified material while exploring the field. Once the explorer has found the material, it will send a
signal and one of the miners will get to the location and start to extract the material. After the signal
has been sent, the explorer will continue exploring the field. Once the extraction is completed, the
miner will stay at that location while waiting for the next signal. The extracted material will be
transported to a storage by a transporter and the transporter will then wait at the storage for the
next signal.
The operations of explorer, miner and transporter can be simulated by using threads based on the
following guidelines.
Each explorer, miner and transporter will be simulated by separate thread. All threads
should run continuously.
When the user presses CTRL+C (to generate an interrupt signal), all the threads should be
cancelled and the application terminates. Refer to Figure 15 as an example.
Assume that
each explorer can find the material within 2-4 seconds, inclusive.
each miner requires 2-5 seconds to extract the material.
each transporter requires 4 seconds (the round trip time) to transport the material
to the storage
Each thread should print a message to indicate its current operation. E.g., an explorer will
print a message indicates that it is exploring the field. Refer to Figure 14 as an example.
Implement the operations described above using POSIX C programming language with pthread for
multithreading and semaphores for mutual exclusion and threads synchronization. The source
codes should be properly commented, and meaningful name should be used for any variable,
function or method. Please implement error handlings in thread creation and semaphore
initialization.
Name the source file as mining_solution.c (This file is to be submitted)
The following screenshot show the example of output when the program is executed. Note that the
output might be different in every execution.help
Task 3 : Synchronisation with semaphores ( 4 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!