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.
What are the four necessary conditions of deadlock prevention? Four essential conditions for deadlock prevention are: 1. Removing the mutual exclusion condition implie
Explain Lexical substitution during macro expansion ? Lexical substitution is used to produce an assembly statement from a model statement. Model statements have 3 kinds of str
Sir/Mam, I want to know the application of Theory of computation in DBMS
Q. Basic need of Random Access Memory? Main memory is Random access memory. It is generally organised as words of fixed length. Length of a word is termed as word length. Every
Give the Schematic of Interpretation of HLL program and execution of a machine language program by the CPU. The CPU utilizes a program counter (PC) to notice the address of nex
A useful exercise in understanding assembly language and its relation to machine language is to take a short assembly language program and translate it to machine language by hand.
SET 2I OF ALL INTEGERS WITH ZERO IS AN ABELIAN GROUP
what is uml ?
What is the Role of Certifying Authority? A certificate authority is a body, that is either public or private, that seeks to fill the requirement for trusted third-party servic
E Brokerage facilitates search & retrieval of Information The success factor of a brokerage is its ability to retain existing clients and to enhance their satisfaction by effec
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