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 is ROM? Read only memory [ROM] is used for storing programs that are permanently resident in the computer and for tables of constants that do not change in value as the pr
Difference between Paperbase and computer base system?
The FontMetrics class is used to describe implementation-specific properties, like ascent and descent, of a Font object.
Linear Array This is a mainly fundamental interconnection pattern. In this processors are linked in a linear one-dimensional array. The intial and last processors are linked w
What is an operating system? An operating system is system software which provides interface between hardware and user. The operating system gives the means for the proper uti
What is the difference between Leave Transaction and Call Transaction? In contrast to LEAVE TO TRANSACTION, the CALL TRANSACTION statement causes the system to start a new SAP
Your task is to implement a memory manager that manages page reads and writes from multiple client threads. In the first programming task the memory manager keeps all the pages in
Goals of this assignment: understanding networking and client server systems. In this assignment, you will write a simple http web server that handles conjunctive search queries (l
Model-View-Controller (MVC) is a design pattern in which "the user input, the modelling of the external world and the visual feedback to the user are explicitly splitted and handle
what are kung classification
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