Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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.|| Let the array be 1 3 4 1 5 6 2 7 1 8 9 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. 1 3 4 1 5 6 2 7 1 8 9 1 2 3 1 3 1 4 6 7 2 O 2 1 In main the output will be 6 1's in the array. To Do List 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago