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.
Your Windows client failed to broadcast to all servers that it has accepted an IP address offer. What step is this in the four-step DORA process? a. Discovery b. Offering c. Reques
To monitor ipx traffic on a network, what command would we use? Ans) show ipx traffic
Describe DHCP concept
Microcells As cells become smaller, antennas move from the tops of tall buildings or hills, to the tops of small buildings or the sides of large buildings, and finally to lamp
A typical layer 2 switch has a number of features. Identify and explain 5 features that you think are important that you would consider in your evaluation of L2 switches offered b
Question: a) In relation to network design, give two reasons why the building-block approach is favoured to the traditional approach. b) Explain the following steps in rela
Ethernet Frame Format Consists of seven fields There is No mechanism for acknowledging received frames considered an unreliable medium
Q. Define transport layer of osi model? - The transport layer regulates information flow to makes sure end-to-end connectivity between host applications reliably and accurately
The Internet Layer The internet layer is responsible for routing the data packets to the appropriate destination. Internet protocol (IP) is responsible for ensuring dat
State the Steps to provide more computing power In order to provide more computing power, the following steps may be taken: Add more processing power by addition of more
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