Information
Do not use pthread_exit() in your code. There is a known issue with valgrind and it causes problems with leak checking. Instead of pthread_exit(), just use a return statement in your code. If you fail to follow these instructions, you will lose points when valgrind complains. Also, make sure you check the return values of the pthreads functions to make sure they were successful. The grader will deduct points if you haven't checked the return values (regardless of whether or not they succeeded).
gcc -g -O -Wall -Wextra -ansi -pedantic -pthread main-thread.c matrix-thread.c -o matrix-threads
where the parameter is the name of a text file that has the matrix in it./matrix-threads matrix.txt
1 2 3 4 5 6 7 8 9 30 36 42 66 81 96 102 126 150
and you would see something like this:./gen_matrix 5 -20 20
You would redirect the output into a file for use by the program:5 16 14 16 12 15 8 8 -16 -19 -6 -17 -2 20 11 5 -15 -6 -10 5 19 16 -4 16 10 5
./gen_matrix 5 -20 20 > mat5.txt
16 14 16 12 15 8 8 -16 -19 -6 -17 -2 20 11 5 -15 -6 -10 5 19 16 -4 16 10 5 156 172 472 312 539 653 346 -226 -387 -399 -713 -380 130 159 91 111 -344 -90 39 -49 -118 80 620 544 559
You need to show me that you actually compiled and ran your program, and used diff to make sure your output is correct. After you've finished coding and testing everything and are sure everything is correct, use the script command to make a text file of your session. From the bash shell in the directory you've setup to test with, run these commands:
Then, press Ctrl-D to end the script session. A file named typescript was created with all of the commands and output. Replace FIRSTNAME and LASTNAME with your real first name and last name. This is how you get your name in the typescript file. Consult the man pages if you want more information on script.script date uptime echo FIRSTNAME LASTNAME pwd whoami uname -a cat /proc/cpuinfo cat /proc/meminfo gcc -g -O -Wall -Wextra -ansi -pedantic -pthread main-thread.c matrix-thread.c -o matrix-threads ./matrix-threads mat16.txt | tee output.txt diff --strip-trailing-cr output16.txt output.txt valgrind -q --leak-check=full --show-reachable=yes --trace-children=yes --tool=memcheck ./matrix-threads mat16.txt doxygen ls -al html/ ls -al latex/
Additional information
Squaring this:
Results in this:1 2 3 4 5 6 7 8 9
Aftering the main thread allocates the memory and reads the input matrix from the file into the memory:30 36 42 66 81 96 102 126 150
After the main thread allocates memory for the resulting matrix:![]()
This is the how the first thread calculates the value:![]()
Row 0:
Column 0:![]()
Writes to first integer in the result matrix:![]()
This is how the 6th thread calculates the value:![]()
Row 1:
Column 2:![]()
Writes to 6th integer in the result matrix:![]()
Aftering each thread has written its result to the matrix:![]()