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.
What is the difference among TFTP and FTP application layer protocols? The Trivial File Transfer Protocol (TFTP) permits a local host to get files from a remote host but does n
Mesh : This is two dimensional networks. In this all processing elements are organised in a two dimensional grid. The processor in the row i and column j are indicated by PE i .
What is horizontal and vertical parity A single error can cause both horizontal and vertical parity checks to be wrong. Two errors can also be easily detected. If they are not
Bridged Ethernet Raises bandwidth by dividing the network into smaller networks allowing concurrent communications Separates collision domains because traffic is lower
Data Distribution Data distribution directives tell the compiler how the program data is to be distributed between the memory areas associated with a set of processors. The log
today, what is the most common or mostly encountered problem in terms of database management system?
Connection Oriented Transport TCP In addition to providing reliable communication transmission control protocols effects errors control flow control and resequencing of
What is the difference among flow control and error control? Ans) Flow control: adjust and confirm data flow rate for successful transmission. Error Control: a method to
Q. Show the Class A Addresses? Class A Addresses Numerically the lowest Use merely one byte to identify the class type and netid Three bytes are obtainable
What are the data units at different layers of the TCP / IP protocol suite? The data unit formed at the application layer is known as a message, at the transport layer the data
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