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.
Can you define the concept of Repeaters, Hubs, Bridges, Switches and Routers?
What is OLTP? In the transaction server, the client component usually contains GUI and the server components usually having of SQL transactions against a database. These applic
What is client/server? Client/server is a type of network wherein one or more computers act as servers. Servers give a centralized repository of resources like printers and fil
Explain in detail about wireless network Think about unseen terminal problem. Imagine a wireless network consist of five stations, A through E, such that each one them is in r
What are Stored procedures? A stored procedure is s named collection of SQL statements and procedural logic that is compiled, verified and kept in a server database. It is typi
In multiprocessing, various processors have to to communicate with each other. Therefore, synchronisation is needed between them. The correctness and performance of parallel execut
Middleware is distributed software required to support interaction among clients and servers. In short, it is the software that is in the middle of the Client/Server systems and it
Solve the following CPM/PERT Network Analysis problem: Given the following network and activity time estimates, determine earliest and latest activity times, slack, the expecte
In collective message passing, all the processes of a set participate in communication. MPI gives a number of functions to execute the collective message passing. Some of them are
Differentiate between Web and Web Page Web or Net The World Wide Web (a server) consisting of a hypermedia system (linking sounds, text, pictures, video) that the com
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