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; } }
}