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 Case Study must be based on the information provided. There will be no additional information. This must be submitted in a .doc, or .pdf format. If you send a few paragraphs i
In distributed routing computation, every packet switch calculates its routing table locally and transmit messages to the neighbors. It also updates information regularly. If a pac
i have been given a question:- any 50 numbers are given and to find out the 1)frequency of odd and even numbers 2)frequency of positive and negative numbers
After studying this part the students will be able to understand about the following: Analysis of Parallel Algorithms; Different Models of Computation; o Interco
Problem: (a) Explain how TCP handles connection-setup management. (b) Each host on the Internet is currently assigned an IP address 32 bits long (IPv4). IPv4 addresses are u
Short for Internet Message Access Protocol. This is another most prevalent protocol of internet standard for email usage apart from POP. Usually all the modern email server and cli
Given the address 172.16.2.120 and the subnet mask of 255.255.255.0. How many hosts are available? Ans) 172.16.2 120 is a standard Class B address with a subnet mask that permit
State the specification of high-end server A mid-range or high-end server with the following specifications would be sufficient for a medium to large organisation: A Pentiu
What are the various security measures A matter of prime concern to companies is the overheads in the form of huge investment on extra hardware and software. It is quite possi
State about transcontinental ?ber A transcontinental ?ber link may have many gigabits/sec of the bandwidth, but latency will also be high due to speed of light propagation abov
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