Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Convert the serial code to code by using POSIX threads and mutex/semphore/barrier . Write a brief report, including the pseudo code and giving an explanation

Convert the serial code to code by using POSIX threads and mutex/semphore/barrier.

Write a brief report, including the pseudo code and giving an explanation why you choose the method

#include #include #include #include main() { srand((unsigned)time(NULL)); int i,n,bin_count,j,p,l=1,k,m; float f,t; float max_meas=0,min_meas=0; float arr[100]; float *q; /* pointer representation of array */ /* q stores the first element address of the array arr */ q=arr; printf("How many random floating point data to be stored : "); scanf("%d",&n); /* float random value insert in array with pointer */ for(i=1;i<=n;i++) { *(q+i)=10*(float)rand()/RAND_MAX; } /* elements in ranom flating values to an array */ printf(" Elements in the array are : "); for(i=1;i<=n;i++) { printf("%0.2f ",*(q+i)); } /* total random float values */ printf(" Total elements : %d",n); min_meas=*(q+0); for(i=0;i*(q+i)) { min_meas=*(q+i); } } /* minimum element value of array */ printf(" Minimum floating point value is : %0.2f ",min_meas); for(i=0;i*(q+j)) { t=*(q+i); *(q+i)=*(q+j); *(q+j)=t; } } } t=round(*(q+0)); /* if bin interval starts from 0 */ printf(" Bin interval details with corresponding float values: "); if(t==0) { i=0; while(l<=bin_count) { /* print bin interval */ printf(" bin %d : %d-%d ",l,i,i+p); printf(": Values : "); for(m=1;m<=n;m++) { if(*(q+m)>=i && *(q+m)<=i+p) /* print the values of random numbers within particular bin interval */ printf("%0.2f ",*(q+m)); } printf(" "); l++; i=i+p; } } /* if bin interval start from 1 */ if(t>0) { i=1; while(l<=bin_count) { /* print bin interval */ printf(" bin %d : %d-%d ",l,i,i+p); printf(": Values : "); for(m=1;m<=n;m++) { if(*(q+m)>=i && *(q+m)<=i+p) /* print the values of random numbers within particular bin interval */ printf("%0.2f ",*(q+m)); } printf(" "); l++; i=i+p; } }

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data And Hadoop Fundamentals Tools And Techniques For Data Driven Success

Authors: Mayank Bhushan

2nd Edition

9355516665, 978-9355516664

More Books

Students also viewed these Databases questions

Question

Define the short-run and long-run and provide an aviation example.

Answered: 1 week ago

Question

Determine miller indices of plane A Z a/2 X a/2 a/2 Y

Answered: 1 week ago

Question

sharing of non-material benefits such as time and affection;

Answered: 1 week ago