Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
Finding prime numbers in a text file using multithreading ( 3 0 % - 1 0 0 marks ) You will be given multiple files
Finding prime numbers in a text file using multithreading marks You will be given multiple files containing a list of numbers. The amount and numbers themselves will be random. You will create a C program which counts the number of prime numbers there are within the file and output to a file the amount of prime numbers found, along with the prime numbers themselves. The aim of this task is to use POSIX threads to parallelise the task to take advantage of the multicore processor within your machine to speed up the task. The threads you spawn within the program must compute an equal or close to an equal amount of computations to make the program more efficient in relation to speed. For this section, as you will only be reading one file and splitting it across many threads determined by argv you should load in the file and split the file into equal parts, then process each slice within your threads. This task also tests your knowledge of dynamic memory allocation. NOTE this program should work with any amount of threads. NOTE Your program only needs to take in one file. We have given you multiple files as they contain a different amount of numbers to test your program with. Creating an algorithm to detect prime numbers marks Using dynamic memory malloc marks Using multithreading with equal computations marks Outputting correct output to a file marks
Finding prime numbers in a text file using multithreading marks
You will be given multiple files containing a list of numbers. The amount and numbers themselves
will be random. You will create a C program which counts the number of prime numbers there are
within the file and output to a file the amount of prime numbers found, along with the prime
numbers themselves. The aim of this task is to use POSIX threads to parallelise the task to take
advantage of the multicore processor within your machine to speed up the task. The threads you
spawn within the program must compute an equal or close to an equal amount of computations to
make the program more efficient in relation to speed. For this section, as you will only be reading
one file and splitting it across many threads determined by argv you should load in the file and
split the file into equal parts, then process each slice within your threads. This task also tests your
knowledge of dynamic memory allocation. NOTE this program should work with any amount of
threads.
NOTE Your program only needs to take in one file. We have given you multiple files as they contain
a different amount of numbers to test your program with.
Creating an algorithm to detect prime numbers marks
Using dynamic memory malloc marks
Using multithreading with equal computations marks
Outputting correct output to a file marks
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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