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.
define the concept of routing protocol?
Q. Example on TCP numbering? Envision a TCP connection is transferring a file of 6000 bytes. The first byte is numbered 10010. What are the sequence numbers for every seg
Output Port The function of the port is take the packets that have been stored in the out put port memory and transmits them over the out going link. The queuing and bu
Question: (a) What is a script kiddie? Is it a significant security threat, and why? (b) Assume that UNIX uses the user login name in lieu of the traditional salt, what is
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
Data Types Each data type of Table 1 must be sent according to the specifications below. [INT] Each value of this type is sent as the string representation of the corre
TCP Segment Structure Figure shows the format of the TCP segment. The header consists of a 20 bytes fixed part plus a variable size options fields. The description o
What are the key design issues of a computer Network? a. Connectivity b. Cost-effective Resource Sharing c. Support for common Services d. Performance
What is SMTP? SMTP is short for Simple Mail Transfer Protocol. This protocol deals with all internal mail, and gives the essential mail delivery services on the TCP/IP protocol
Name the basic components of the router?
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