+
COMPILE AND RUN THE PROGRAM ON A LINUX SYSTEM. FIND OUT WHAT...

COMPILE AND RUN THE PROGRAM ON A LINUX SYSTEM. FIND OUT WHAT...

Rating:
Rating
(0)
Author: Carol 96
Description:

http://theperfecthomework.com/compile-and-run-the-program-on-a-linux-system-find-out-what-results-it-produces-and-explain-the-results/

COMPILE AND RUN THE PROGRAM ON A LINUX SYSTEM. FIND OUT WHAT RESULTS IT PRODUCES AND EXPLAIN THE RESULTS.

This program creates a new thread. Both the main thread and the new thread then increment the variable counter 20 times. But the program itself produces some unexpected results. 1. Compile and run the program on a Linux system. Find out what results it produces and explain the results.Compile as follows:$ gcc thread2.c -o thread2 -lpthread Run using the following command$ ./thread2 2. Modify the program so that the variable counter has a value of 40 when the program ends. Hint: use synchronization primitives. Please submit a zip file labelled as Assignment4_Yourname.zip. It should include a PDF file with explanation of the results and a C source file with the modified program.Clarification: One some systems, you might not see the unexpected result right away. In that case, run the program several times and see if you get any unexpected results. If you still don't see anything, insert some sleep statements into both the thread functions and manually study the code and point out what's wrong with the code. Download Attachment: assignment4.c.rtfAdditional Requirements Level of Detail: Show all work Other Requirements: Study the example program in the attached file. This program creates a new thread. Both the main thread and the new thread then increment the variable counter 20 times. But the program itself produces some unexpected results. 1. Compile and run the program on a Linux system. Find out what results it produces and explain the results.Compile as follows:$ gcc thread2.c -o thread2 -lpthread Run using the following command$ ./thread2 2. Modify the program so that the variable counter has a value of 40 when the program ends. Hint: use synchronization primitives. Please submit a zip file labelled as Assignment4_Yourname.zip. It should include a PDF file with explanation of the results and a C source file with the modified program.


(more)
See More
Try a College Course Free

Sophia’s self-paced online courses are a great way to save time and money as you earn credits eligible for transfer to over 2,000 colleges and universities.*

Begin Free Trial
No credit card required

25 Sophia partners guarantee credit transfer.

221 Institutions have accepted or given pre-approval for credit transfer.

* The American Council on Education's College Credit Recommendation Service (ACE Credit®) has evaluated and recommended college credit for 20 of Sophia’s online courses. More than 2,000 colleges and universities consider ACE CREDIT recommendations in determining the applicability to their course and degree programs.

Tutorial