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!
Example Programmes for Parallel Systems
Now we shall complete this with the examples on shared memory programming.
Example 13: Adding elements of an array using two processor int sum, A[ n] ; //shared variables
void main ( ){
int i ;
for (i=0; i // now create process to be implemented 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 implemented 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, the last half of the array is passed to processor P1 which adds them. Meanwhile processor P0 adds the first half of the array. The variable sum is locked to avoid inconsistency.
// now create process to be implemented 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 implemented 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, the last half of the array is passed to processor P1 which adds them. Meanwhile processor P0 adds the first half of the array. The variable sum is locked to avoid inconsistency.
Write the definition of IPX and UDP IPX: Inter-network Packet Exchange supports the transport and network layers of the OSI network model. It provides fast, unreliable, communi
Question : (a) List down and explain the different signal propagation behaviours that radio waves exhibit. (b) Explain the term Delay Spread with reference to signal propaga
Ask Design private subnetworks (using Class A range for CIDR) for each domain as in the table below, and complete the table. Hints: Consider how many network bits are required to a
a transperent switch is inserted between two local area networks ABC and XYZ.network ABC has workstation 1,2,and 3 and Network XYZ has workstation 4,5, and 6. show the contents of
Can you Describe the concept of Layer 3 switches
Question 1 How can one set up internet on a PC and test it?? Explain Setting up a new connection Testing internet connection Question 2 What are the rules for wri
The following DNA sequences are extracted from promoter region of genes which are co-regulated by the same transcription factor (TF). The nucleotide segments capitalized in the giv
Operating system for Server Since 1994, when the original pair of web servers - NCSA HTTPd and CERN HTTPd , were proposed, dozens of commercial and shareware programs have
UNIX For Multiprocessor System:- The UNIX operating system for a multiprocessor system has a number of additional features as compared to the normal UNIX operating system. Let
ROLE OF DESIGN IN ACHIEVING RELIABILITY One of the most important methods for achieving high reliability is through design. Use reliability cannot be higher than the design re
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