Already have an account? Get multiple benefits of using own account!
Login in your account..!
Remember me
Don't have an account? Create your account in less than a minutes,
Forgot password? how can I recover my password now!
Enter right registered email to receive password!
Q. Show the Programmes for Parallel Systems?
Adding elements of an array using two processor
int sum, A[ n] ; //shared variables
void main ( ){
int i ;
for (i=0; i scanf ("%d",&A[i] ); sum=0; // now create process to be executed by processor P1 fork(1) add (A,n/2,n-1, sum); // process to add elements from index n/2 to - 1.sum is output variable // now create process to be executed by processor P0 add (A,0,n/2-1, sum); join 1 ; printf ("%d", sum); } add (int A[ ], int lower, int upper, int sum) { int sum1=0, i; for (i=lower; i<=upper; i++) sum1=sum1+A[i]; lock sum; sum=sum+sum1; unlock sum ; } In this program last half of array is passed to processor P1 that adds them. For the meantime processor P0 adds the first half of array. The variable sum is locked to avoid inconsistency.
scanf ("%d",&A[i] );
sum=0;
// now create process to be executed by processor P1
fork(1) add (A,n/2,n-1, sum); // process to add elements from index n/2 to -
1.sum is output variable // now create process to be executed by processor
P0 add (A,0,n/2-1,
sum);
join 1 ;
printf ("%d", sum);
}
add (int A[ ], int lower, int upper, int sum)
{
int sum1=0, i;
for (i=lower; i<=upper; i++)
sum1=sum1+A[i];
lock sum;
sum=sum+sum1;
unlock sum ;
In this program last half of array is passed to processor P1 that adds them. For the meantime processor P0 adds the first half of array. The variable sum is locked to avoid inconsistency.
In binary representation there are some states that are believed to be never occurred because of some particular functionality of a given circuit. If zero output is assigned to suc
Describe the construction and working of michelson iinterferometer.describe the formation of different types of fringes in Michaelson''s interferometer
How do you find out the flaw, which of the address getting written wrongly. Fill the full memory once with either random data or sequential data then after filling totally rea
The various memory allocation functions are described below: (i) malloc( ) : It is a memory allocation function that assigns requested size of bytes and returns a pointer to t
Secondary storage: Secondary storage (or external memory) differs from primary storage in that aspect it is not accessible by the CPU directly. The computer typically uses its
Conversion of fractional number 0.6875 into its equivalent binary number ? Ans. Multiply the fractional number 0.6875 with 2 until the remainder becomes 0 that is, Ther
What is write-back or copy-back protocol? For a write operation using this protocol during write-hit: the method is to update only the cache and to mark it as updated with an a
Q. Explain Increments and skips subsequent instruction? Increments A and skips subsequent instruction if the content of A has become 0. This is a complex instruction then requi
Explain the working of Interpreter? The Interpreter is a program that executes instructions written in a high-level language. There are two manners to run programs written in a
i read in b.tech 3year.i can go to hadrabad becouse read of branch parer.why the best instituies in hadrabad in purpus gate and branch paper
Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!
whatsapp: +91-977-207-8620
Phone: +91-977-207-8620
Email: [email protected]
All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd