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 uses of Intranet Intranet can largely eliminate paper-based documents, which otherwise become outdated over passage of time. Increased communication will also lead t
Network Allocation Vector Timer which shows how much time must pass before a station is allowed to check the channel
Q. Show the Use of flow control? Flow control denotes to a set of procedures used to restrict the amount of data that the sender can send before waiting for Error Control
What are the advantages of bus topology? The benefit of physical bus topology is: a. It uses established standards and it is relatively simple to install. b. It needs les
Write the characteristic of Store and Forward switches? A) Store and Forward switch will not forward fragments. B) The longer the frame, the longer the delay (latenc
Identify the 3 major functions at layer 3 of the OSI model Ans) Layer three explains the path, forwards the packet and executes software / logical addressing.
XYZ INC. is a large manufacturing firm that operates 5 factories in Dallas, 4 factories in Los Angeles, and 5 factories in Albany, New York. It operates a tightly connected order m
ACME Corp is located in Toledo, Ohio. They would like to create a network and divide it into 3 subnets, each subnet has 150 computers. The IT plan calls for connecting the LAN to t
write on everything on telecommunication
Q. How to connect Remote LANs? - Remote bridges acting as connecting devices to connect LANs and point-to-point networks such as leased telephone lines or ADSL lines
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