Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

NEED MAKEFILE 1. When your program starts, it shall do the following: 1. Create

ID: 3557953 • Letter: N

Question

NEED MAKEFILE

1. When your program starts, it shall do the following:
1. Create a file, SHARED.txt, in the current directory (cwd).
2. Write it's pid (Process ID) followed by a Carriage Return and Newline in the file.
3. Close the file SHARED.txt
4. Create a semaphore named SEM which the threads will use to manage access to the file
SHARED.txt.
5. Create 6 threads. Use the POSIX version of threads (i.e., pthread_create())
6. Block/wait for all six threads to complete their work.
7. Destroy the semaphore, then exit gracefully, printing a friendly message to the console
2. Each thread shall perform the following (note, each thread is running concurrently):
1. Periodically (even numbered threads - once every two seconds, odd numbered threads

Explanation / Answer

your programs runs fine on linux
use g++
commands are :-

g++ thread.cpp -o thread -lpthread
./thread

done :)_