Question
Write a combination of four C Language functions. The first program should include a test_prime() function that returns a 0 if the integer argument is
Write a combination of four C Language functions.
The first program should include a test_prime() function that returns a 0 if the integer argument is not a prime number, and a 1 if it is a prime number using function int test_prime(int n);
The second program should also use a prime_search() function used to start a routine for the prime search threads. It should have a range of integers and determine which integers in that range are prime. Each prime number should be printed on a separated line to a file named primesx, where x is the thread number using function void *prime_search(void *param);
The third program should include a mini_shell() function that serves as a start routine for the interactivity thread. This function will display a prompt and take commands from the user using function void *mini_shell(void *param)
The following single character commands must be supported: 1 : will return the integer prime search thread 1 is currently checking 2 : will return the integer prime search thread 2 is currently checking a : will return the integers both prime search thread 1 and 2 are currently checking
The fourth program includes a main() that searches the first five million integers for prime numbers by using two threads. A third thread is created to enable the user to check the search status of the two prime search threads while they are running. When the prime number search is completed the main function will combine the three functions.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started