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.
i want to make an assignment about kirchoff''s law
The larger the Grade of Service, the worse is the service given, it is true or false. Ans: It is true that larger the Grade of Service, the worse service is provided.
In this stage of the project you are required to create a Design document, the Design document must contain the following: Structure chart Pseudo-code Data Dictionary
State the features of Pentium series of microprocessors: Pentium is a 32-bit superscalar, CISC microprocessor. The term superscalar is used for processor that contains more th
Which method is used for resolving data dependency conflict by the compiler itself? (A) Delayed load. (B) operand forwarding. (C) Pre fetch target instruction. (D) loo
Learning Abilities of Perceptrons: Conversely computational learning theory is the study of what concepts particular learning schemes as representation and method detail as a
Explain the necessary conditions for deadlock to occur. Conditions for deadlock to arise are: i. Mutual exclusion: At least one resource must be held in a non-sharable mo
Indirect addressing mode - assembly language: The Indirect addressing mode and the address field of the instruction refers to the address of a word in memory, which in turn co
Assembler directives: An assembler directive is a statement to give direction to the assembler to perform the task of assembly process. Assembler directives control organizati
why to learn data base?
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