Question: Write a C program which implements Pthreads. Use #include The program must create 2 threads calling different function. The functions must include some arbitrary calculation

Write a C program which implements Pthreads.
Use #include
The program must create 2 threads calling different function. The functions must include some arbitrary calculation which takes processing time. Use the following code:
Function 1 sample code:
long sum =0;
for (long i =0; i <1000000000; i++){
sum +=1;
}
Function 2 sample code:
long sum =0;
for (long i =0; i <5000000; i++){
sum +=1;
}
Successfully compile and run 2 threads using the sample code above for each function (8 Marks).
After each thread completes print out that it has completed (2 Marks).
Expected Output:
Thread 1 complete
Thread 2 complete

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!