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.
how to find the integral of a function represented by collection of experimental data
What are the difference between heap and stack? The Stack is more or less responsible for maintaining track of what's executing into our code or what's been "called". The Heap
Algorithm to insert a key in B-tree is as follows: 1. First search is completed for the place where the new record must be put. As the keys are inserted, they are sorted into
What is virtual memory? Virtual memory is a method used in some large computer systems that allow the user to construct program as by a large memory space were available, equal
To execute sparse matrix dynamically, Which data structure is used Linked List data structure is used to execute sparse matrix dynamically
Explain Elimination of common sub expression during code optimization An optimizing transformation is a regulation for rewriting a segment of a program to enhance its execution
How society is affected thorugh Internet Buying goods and services (for example banking) over the internet has both negative and positive aspects on society. These can be expl
What is virtual address? The binary address that the processor used for either instruction or data known as virtual address.
Predicates in propositional model: The predicates take a number of arguments in which for now we assume are ground terms and represent a relationship between those arguments t
Define interrupt. An interrupt is any exceptional event that causes a CPUU to temporarily transfer control from its present program to another program , an interrupt handler th
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