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

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....
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 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 program for hotel booking system using C++ Program Requirement 1. You can write any...
Write a program for hotel booking system using C++ Program Requirement 1. You can write any program based on the title assigned. 2. The program must fulfill ALL the requirements below. The requirements listed below are the MINIMUM requirement. Your program may extend beyond the requirements if needed. a) Create at least one (1) base class. b) Create at least two (2) derived classes that inherit from the base class created in 2(a). c) Create at least one (1) object...
Write a program using C language that -ask the user to enter their name or any...
Write a program using C language that -ask the user to enter their name or any other string (must be able to handle multiple word strings) - capture the epoch time in seconds and the corresponding nanoseconds - ask the user to type in again what they entered previously - capture the epoch time in seconds and the corresponding nanoseconds -perform the appropriate mathematical calculations to see how long it took in seconds and nanoseconds (should show to 9 decimal...
Write a C program which fork the process and have the child execute a process.You have...
Write a C program which fork the process and have the child execute a process.You have to implement void forkexec(char** argv).This takes in an array of strings representing arguments.The first argument is the filename of an executable (which will be given as a "./a").The remaining terms would be arguments for said executable.The array is null terminated and you need to fork your process.The child needs to call exec/execvp to execute the specified file with the specified arguments. Also have the...
Using C++ Write a program to calculate the amount a customer should pay in a checkout...
Using C++ Write a program to calculate the amount a customer should pay in a checkout counter for the purchases in a bagel shop. The products sold are bagels, cream cheese, and coffee. Use the pseudo code discussed in the class to write the program. Make reasonable assumptions about the prices of bagel, cream cheese, and coffee. Declare prices of bagel, cream cheese, and coffee as constants.
WITHOUT USING POINTERS. This is C programming. I am writing a program which should calculate standard...
WITHOUT USING POINTERS. This is C programming. I am writing a program which should calculate standard deviation of an array of exam scores and then add the standard deviation to each array element. It should print the original array, the standard deviation, and the new rounded adjusted array. I included my question as a comment in the line of code that is giving me an issue. (Removing the a from E-x-a-m as Chegg doesn't allow the word.) #include <stdio.h> #include...
use C++ Write a program to calculate the frequency of every letter in an input string...
use C++ Write a program to calculate the frequency of every letter in an input string s. Your program should be able to input a string. Calculate the frequency of each element in the string and store the results Your program should be able to print each letter and its respective frequency. Identify the letter with the highest frequency in your message. Your message should be constructed from at least 50 letters. Example of Output: letters frequency a 10 b...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT