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.
Round Trip Time (RTT) and Time Out The size and the complexity of computer networks have grown in past years. To achieve an efficient and reliable transmission some
Submission instructions: Answer the following questions using a text processing software and submit your answers via connex. Possible file formats for your submission file(s) are .
Recognize the two items that TCP and UDP share in common? Ans) TCP and UPD are both layer 4 Transport protocols and both use port number to recognize upper level applications.
Tree interconnection network: In tree interconnection network, processors are organised in a complete binary tree pattern. Figure: Tree interconnection network
What are firewalls? Firewalls serve to protect an internal network from external attacks. These external threats can be hackers who need to steal data or computer viruses that
Q. Show the Go-back-N - Control Variables? - S- holds the series number of the recently sent frame - SF - holds sequence number of the first frame in the window - SL - ho
Question 1: a) Give three examples of Shells in Linux. b) Differentiate between the Join command and the Paste command in Linux, use an example to support your answer.
INTRODUCTION This part discusses the additional requirements at software levels and operating system which will create the parallel programs run on parallel hardware. Collecti
using binary adition, what is the result of 1010 + 10? Using binary addition, how would you repeatedly increment a number by 2?
Hubs/Repeaters Hubs/Repeaters are used to connect together two or more network segments of any media type. In larger design, signal quality starts to deteriorate as segment exc
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