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.
Thinnet Characteristics Shorter range (185 meters) as well as smaller capacity Bus topology LAN Connectors and cables include: thin coaxial cable, NICs and BNC-T
What is Error Control ? Error control is both error detection and error correction. It allows the receiver to inform the sender of any frames lost or damaged in transmission an
What is primary and secondary ring One of the two FDDI rings is known as the primary ring; the other is called the secondary ring. The primary ring is utilized for data tra
What is workstation? A workstation is a node in network that is more useful and can occur local information processing or graphics processing. A workstation generally has an in
The address recorded by a router should be its outgoing interface. That is, if a router forwards a datagram that has the record route option enabled, and if the datagram arrives at
What is Sliding Window? The sliding window is an abstract method that explains the range of sequence numbers that is the concern of the sender and receiver. In other words, he
Explain the Multipath resistance The chipping codes used for CDMA not only exhibit low cross-correlation but also low autocorrelation. Thus, a version of the signal that is del
What are instance variables? Instance variables are those which are explained at the class level. Instance variables require not be initialized before using them as they are au
Describe the concept of internetwork and intranetwork routing protocols?
Q. Evaluate Error Detection in CRC Polynomials? The divisor in the CRC generator is most habitually represented as an algebraic Polynomial. Reasons: It is short
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