Question: I have this OS assignment that is due in a week please help its about threading and i have to do it with linex which
I have this OS assignment that is due in a week please help its about threading and i have to do it with linex which i do not know here is the file
In this assignment, you will implement a multi-threaded program (using C/C++) that will generate a simplified version of the Image Processing-2D Median Filter (link). The program will create T worker threads that will operate on the input image and create a new image after applying the filter (T will be passed to the program with the Linux command line). Each of the threads works on a part of the input image. After applying the median filter, each pixel (cell in matrix) will have the value of the median of the original values of all its 8 neighboring pixels and itself (i.e. total of 9 pixels). For pixels in the boundaries where they are missing some neighbors, we can assume the value Zero for these neighbors when calculating the median. Your program should have three global shared variables to report the statistics of the pixels after applying the filter (i.e. in output image): 1. numOfBright: Will track the total number of pixels that have a value greater than 200. 2. numOfDark: Will track the total number of pixels that have a value less than 50 3. numOfNormal: Will track the total number of pixels that have (x) such that 50<=x<=200 When any of the threads starts executing, it will print its number (0 to T-1), and then the range in the image that it is operating on. Then, when any thread is done, it will print the statistics of pixels it found in its portion. Finally, when all threads are done, the main should print the statistics of all pixels in the entire image. You should write two versions of the program: The first one doesnt consider race conditions, and the other one is thread-safe. The input will be provided in an input file (in.txt), and the output should be printed to an output file (out.txt). The number of worker threads (T) will be passed through the command line, as mentioned earlier. The input will start with an integer value N, representing the dimensions of the input image.
Then, an NxN matrix representing the input image (each pixels value is an integer between 0-255). All the printing messages about statistics (from threads and main) will be printed to the standard output (STDOUT). The resulting output image (matrix) will be printed to the output file (out.txt).
In this assignment, you will submit your source code files for the thread-safe and thread-unsafe versions, in addition to a report (PDF file). The report should show the following: 1. Screenshot of the main code 2. Screenshot of the thread function(s) 3. Screenshot highlighting the parts of the code that were added to make the code thread-safe, with explanations on the need for them 4. Screenshot of the output of the two versions of your code (thread-safe vs. non-thread-safe), when running passing the following number of threads (T): 1, 4, 16, 64, 256, 1024. 5. Based on your code, how many computing units (e.g. cores, hyper-threads) does your machine have? Provide screenshots of how you arrived at this conclusion, and a screenshot of the actual properties of your machine to validate your conclusion. It is OK if your conclusion doesnt match the actual properties, as long as your conclusion is reasonable.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
