Question: Can you please write the code in C. Write a program to accept an array of 20 elements and a number to search in the

Can you please write the code in C. Can you please write the code in C. Write a program

Write a program to accept an array of 20 elements and a number to search in the main function, both array and the search-number should be global variables. Write a thread function to search and count the occurrence of the given number. Give a sleep (4) inside the loop in the thread function to model a big process working. Call 5 thread function to do search in 5 separate sections of the array. After calling all function join all threads together and in main function display the occurrence of the number in that array. If there is a race condition identify and synchronize to get the correct output. Example Let the array be 1 3 4 1 5 6 2 7 189 1 2 3 1 3 1 4 6 7 And let the number to search is 1. Divide the array into 5 and call the same thread function to count the occurrence of 1 in that section. 13 4 1 5 6 2 7 1 8 9 1 2 3 1 3 1 4 6 7 2 0 2 1 1 In main the output will be 6 1's in the array. Rubrics: Defining variables: 10 points Properly calling thread functions -10 points Thread function -20 points Sleep () called-5 points Synchronized- 25 points

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!