Question

In: Computer Science

Use any C program without using PTHREADS calculate time taken to execute program. Write same program...

Use any C program without using PTHREADS calculate time taken to execute program.

  1. Write same program of question 1 using PTHREADS. Calculate time taken to execute program.(1 mark)
  2. Identify data races in above program and explain why this situation occurred with an example (1 mark)
  3. Rewrite the code to avoid data races should use any of the THREE techniques.(1.5 marks)

please I need the c code..

critical section

mutex solution

semaphore functions

Barriers

Read-Write Locks

Run program using 1, 2, 4, and 8 threads Comparison study (1.5 marks)

Number of threads

Implementation

1

2

4

8

critical section

mutex solution

semaphore functions

Barriers

Read-Write Locks

  1. Rewrite the program using OPENMP. Run on 4 processors. Calculate time taken.
  2. At the end calculate speed up.

Solutions

Expert Solution

THANK YOU! PLEASE GIVE M,E THUMS UP


Related Solutions

Use any C program without using PTHREADS calculate time taken to execute program. Write same program...
Use any C program without using PTHREADS calculate time taken to execute program. Write same program of question 1 using PTHREADS. Calculate time taken to execute program. Identify data races in above program and explain why this situation occurred with an example Rewrite the code to avoid data races should use any of the THREE techniques. critical section mutex solution semaphore functions Barriers Read-Write Locks Run program using 1, 2, 4, and 8 threads Comparison study Number of threads Implementation...
Using C Write a program that will serve as a simple shell. This shell will execute...
Using C Write a program that will serve as a simple shell. This shell will execute an infinite for loop. In each iteration of the loop, the user will be presented with a prompt. When the user enters a command, the shell will tokenize the command, create a child process to execute it and wait for the child process to be over. If the user enters an invalid command, the shell should recognize the situation and show a meaningful message....
(using C in a Linux environment and the POSIX pthreads library) Write a program named Sort.c...
(using C in a Linux environment and the POSIX pthreads library) Write a program named Sort.c that accepts a list of numbers from the user. There are two threads: Main thread waits for the numbers to be entered by the user and for the second thread to finish sorting. It then asks user whether there are more lists or not. It will do this until the user indicates there are no more lists to be entered, at which point it...
Write a C or C++ program that uses pthreads to compute the number of values that...
Write a C or C++ program that uses pthreads to compute the number of values that are evenly divisible by 97 between a specified range of values (INCLUSIVE). The program should accept 3 command-line arguments: low value high value number of threads to create to perform the computation -Specifics for program order of input: 0 9000000000 2 this means 0 to 9 Billion (INCLUSIVE); 2 threads alarm(90); this should be the first executable line of the program to make sure...
6.5 The time taken by machines A, B, and C to execute a given task is...
6.5 The time taken by machines A, B, and C to execute a given task is A 16m, 9s B 14m, 12s C 12m, 47s What is the performance of each of these machines relative to machine A? 6.6 Why is clock rate a poor metric of computer performance? What are the relative strengths and weaknesses of clock speed as a performance metric? 6.7 What are the relative strengths and weaknesses of the MIPS as a metric of computer performance?
Write a Pthreads program 'Dining-Philosophers.c' to implement the classical 'Dining-Philosophers'problem by using Pthreads mutex locks and...
Write a Pthreads program 'Dining-Philosophers.c' to implement the classical 'Dining-Philosophers'problem by using Pthreads mutex locks and condition variables. To implement the program, please followthe hints below. (a) The detailed 'Dining-Philosophers' problem statement: Refer to Page 71 ~ Page 72 in 'Lecture-08.pptx'    (b) The introduction to Pthreads mutex locks and condition variables: Refer to Page 17 ~ Page 39 in'Lecture-08.pptx'    (c) Creating five philosophers, each of which will run as a separate thread. Philosophers alternatebetween thinking and eating: The activities...
I need to write a C++ program that appends "not" into the string without using the...
I need to write a C++ program that appends "not" into the string without using the append method or any standard libraries. It should return the string if there isn't an "is" in it. Examples: is is = is not is not This is me = This is not me What is yellow? = What is not yellow? The sky is pink = The sky is not pink isis = isis What happened to you? = What happened to you?
Write a 'C' program to calculate the surface area of the cone and by using that,...
Write a 'C' program to calculate the surface area of the cone and by using that, also calculate the volume of the cone and print the values as surface area of the cone and volume of the cone. where as: surface area of the cone = πr2 (r is the radius of the surface) volume of the cone = (1/3)πr2h (h is the height of the cone)
Write a C++ program to calculate the time to drain a cylindrical water tank for an...
Write a C++ program to calculate the time to drain a cylindrical water tank for an initial water height ranging from 1 to 10 feet (specifically for 1, 2, 4, 6, 8, and 10 ft). The tank has a radius (rt) of 2 feet and the drain radius (rd) is 0.3 inch. The gravitational constant (g) is 32.2 feet/sec2. The formula for time to drain the tank is time=(rtrd)2h/vavg where, average velocity, vavg=0.5(2gh).5 In your program, assign the values to...
Write a C program without using if-else construct that does the following. It accepts a sequence...
Write a C program without using if-else construct that does the following. It accepts a sequence of positive integers between 1 and 9 both inclusive from the keyboard. The program will stop accepting input once an integer outside the range is entered. The program will finish by printing the total number multiples of 3 and total number of even integers entered. Test data and expected output: Enter integers between 1 & 9 both inclusive, outside range to stop Enter integer...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT