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.
Cube: It's a 3 dimensional interconnection network. In Cube PE s are organised in a cube structure. Figure 11: Cube interconnection network
Hierarchy of DNS Servers DNS uses a large number of server organized in hierarchical fashion and distribution around the world. No single DNS server has all of the mappin
What are the Call routers Call routers A, B, C, D, and E. There are ten potential lines: AB, AC, AD, AE, BC, BD, BE, CD, CE, and DE. Each of these lines has four possibilities
Q. Why we use numbering frames? Why numbering frames? Stop--and-wait ARQ, 1. Numbering Frames prevents the retaining of duplicate frames.. 2. Numbered acknowled
State the Example of security audit as case study Linda narrates one of her experience about a security audit. She was performing a spot audit where she was checking certain
Write the layer on which layer does L2F, PPTP and L2TP operate?
Torus: The mesh network with wrap around connections is termed as Tours Network. Figure: Torus network
State the types of performance of computer hardware The hardware, i.e., the server or computer has a direct relationship on performance in the following areas: Reliabili
Cost Saving Better performance scalability and viability translates into saving for website operators. Because fewer application web servers are required to meet
Q. Show the Routing Table? Routing Table Every router remains a routing table that has one entry for every destination network of which the router is aware Proces
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