You are expected to write a C program using threads and semaphores to implement critical sections. First, copy the following shell script into a new.sh file. When executed, it will create a new directory and fill it with 20-30 files, each containing 1000 random integers.You must design your program to accept two parameters from command line, the directory containing generated txt files (myDir) and the number of simultaneously active threads. Your program must open the directory passed to it as a command line argument (for example, "./hw2 directoryName threadNumber"). The program is to use threads to compute the number of prime numbers in each file and print thread by thread. The number of active threads at a time is to be limited to threadNumber. Hint1: use a semaphore (mutex) to limit the number of simultaneously active threads (threadNumber). Create a threads whenever an active thread terminates. The program must work for any number of files. Hint2: you may check number of active threads per process by executing "ps -elf" command in a second terminal window under NLWP column, after the program starts execution. Notes about the problem: You may think of this problem as if an unknown number of students are queued in front of an instructor's office to see their exam papers. But the instructor's office can only host at most n (threadNumber) students. So, the new student can enter the room only when one of the students inside leaves. Execute your program observing time data: time
/
hww 2 myDir 1 time ./hw2 myDir 2 Note that "time" is a system utility, which displays total execution time details of the executing program. Let the output of one of the runs be similar to the following. Thread 1 has found 6454 primes in file1.txt ... Thread 5 has found 23935 primes in file2.txt "- real 0 m 54.277 s user 1m48.500s sys 0m0.044s This sample output shows that this execution took 54.277 seconds. Repeat the execution 8 times, each time with different number of simultaneously active threads. Prepare a table showing how the times change with the number of simultaneous threads, similar to the one as follows: \table[[THREADS,REAL,USER,SYS],[1,,,],[2,,,],[3,,,],[
dots
,,,]] As the number of simultaneous threads increases, report the changes you observe for real, user, and sys values. Increase the number of files and the file sizes by changing the shell script for higher variations. Submission requirements: Well-documented source file (yourID_hw2.c) Output of each run (yourID_hw2Output.pdf) Thread timing table and report on the changes (youriD_hw2-Report.pdf)