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.
SELECTIVE COMPLEMENT The selective-complement process complements bits in register A where there are corresponding 1's inside register B. It does not affect bit positions which
PRINCIPLES OF COMPOSITION The principles of composition are the way that the elements of composition are used to achieve a particular purpose. Some of the main principles of co
for calculating simple interest
What are the Steps include constructing a Functional Model Recognize input and output values Build data flow diagrams which shows functional dependencies Explain
Q. Define Print Resolution of printers? Print Resolution is the detail which a printer can give considered by how many dots a printer can put in each inch of paper. So the uni
Explain SNMP (simple network management protocol). Once SNMP is used the management station sends a request to an agent asking this for commanding or information this to update
What is the difference between a Substructure and an Append Structure? In case of a substructure, the reference originates in the table itself, in the form of a statement
Q. Show the steps of execution of instructions? Fetch First Instruction into CPU: Step 1: Find/calculate the address of first instruction in memory. In this machine illust
Central processing unit (CPU) : The part of the computer which executes program instructions is known as the processor or central processing unit (CPU). CPU is over single ele
Which of following requires refreshing SRAM., DRAM., ROM. or EPROM. ? Ans. DRAM. requires refreshing.
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