Question: For this assignment, you will write your first parallel program using pthreads. This program should be invoked as follows: ./minions k The above line means

For this assignment, you will write your first parallel program using pthreads. This program should be invoked as follows: ./minions k The above line means the users typed in the name of our test program ./minions and gave it one command line argument. This program will spawn k threads. Each thread will print Hello! I am minion x to stdout. x is a unique number from 0 to k 1 representing the thread ID, e.g. the first thread created will be minion 0. All of these threads should run concurrently. Once all the threads have terminated, create an additional thread that says: Hello Minions! I am the Overlord!. You should create a Makefile that can compile your program on Centaurus. Your program needs to run on Centaurus. You should submit a slurm batch file that executes your program with 40 threads.

Your threads output may overwrite each other. This is normal; we have not discussed race conditions yet. However, the Overlord should print last. Make sure the Overlord is a new thread and not the main thread. Assumptions and Errors Your program should ensure that threads are created properly. If pthread create fails, print Failed to create pthread, error code X. You should print the returned error code in place of X, and also exit with the same error code.

Your archive should include these files only: minions.c Makefile README slurm.out README should include a small description of what difficulties you had in this project. A slurm.out file produced by slurm. This file will be created automatically with a slightly different name when you submit a job with sbatch. This will demonstrate that you tested/ran your code at least once. Create your own Makefile. Follow good compilation standards. Your Makefiles MUST produce a compiled executable named minions

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 Databases Questions!