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.
Configure VTP Pruning on the Switche s VTP pruning allows a VTP server to suppress IP broadcast traffic for particular VLANs to switches that do not have any ports in that VLAN.
Write the definition of IPX and UDP IPX: Inter-network Packet Exchange supports the transport and network layers of the OSI network model. It provides fast, unreliable, communi
In Novell's use of RIP, there are two metrics used to make routing decisions. What are they? Ans) A. Ticks. B. Hops
What is a OSI layer 2 device called a "barter"?
Firewall is a device or a component that restricts access between a protected or an internal network from an external or untrustworthy network .A firewall basically limits unautho
Q. Subnet layer of the TCP-IP model? These two layers of the OSI correspond straight to the subnet layer of the TCP/IP model. Majority of the time the lower layers under the
What protocol can be applied when you need to transfer files between different platforms, such among UNIX systems and Windows servers? Use FTP (File Transfer Protocol) for file
What is Stop-and-Wait Automatic Repeat Request? Error correction in Stop-and-Wait ARQ is implemented by keeping a copy of the sent frame and retransmitting of the frame when th
Wait protocol The wait protocol is used for resolving the conflicts, which arise due to number of multiprocessors demanding the same resource. There are two types of wait prot
Explain Network Services Network services are the thing that a network can do. The main networking services are File Services: This contains file transfer, storage, data m
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