Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Network & Security Expert

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.

Computer Network & Security, Computer Science

  • Category:- Computer Network & Security
  • Reference No.:- M9525915

Have any Question?


Related Questions in Computer Network & Security

Research assignmentproduce a formal 2000 word report in the

Research Assignment Produce a formal 2000 word report, in the format described in the supplied "Reports format and style" document, examining the various "Transition from IPv4 to IPv6". You are to research and compare th ...

Objectives-to learn about more advanced network security

Objectives -To learn about more advanced network security and vulnerability scanning tools Lab Outcome: · To complete the lab procedures & correctly answer the questions in the Blackboard quiz. Lab Deliverables · Answer ...

Task1 in each of the following scenarios there is a

Task 1. In each of the following scenarios there is a relationship to work life in the IT industry. With each of the following question, ensure that your answer includes the explanation of how it would be applied to work ...

Suppose there is no inflation and an insurance company

Suppose there is no inflation and an insurance company offers a contract that would pay $500,000 with certainty 50 years from now. What is the most that this contract would be worth today if: 1. The rate of interest is 7 ...

Toms income is 480and he spends it on two goods x and y his

Tom's income is $480and he spends it on two goods, X and Y. His utility function is U = XY. Both X and Y sells for $8 per unit.   a. Use lagrangian function to calculate Tom's utility-maximizing purchases of X and Y.  b. ...

Advanced network design assessment - human factors in

Advanced Network Design Assessment - Human factors in network analysis and design Purpose of the assessment - This assignment is designed to assess students' knowledge and skills related to the following learning outcome ...

Advanced network design assessment - human factors in

Advanced Network Design Assessment - Human factors in network analysis and design Purpose of the assessment - This assignment is designed to assess students' knowledge and skills related to the following learning outcome ...

Network project management assignment -purpose of the

Network Project Management Assignment - Purpose of the assessment - The purpose of this assignment is to build a clear understanding of project management fundamentals and their application, specifically: demonstrate pro ...

Question explain the meaning of computer networkingexplain

Question: Explain the meaning of computer networking. Explain the meaning of Information and give at least three examples of it. The response must be typed, single spaced, must be in times new roman font (size 12) and mu ...

If a router is attached to a network with a base ip address

If a router is attached to a network with a base IP address of 198.10.0.0/20 and receives a packet addressed to 198.10.10.144, answer the following questions: a. What is the network mask used by the router? (in dotted de ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As