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!
Q. Show the Programmes for Parallel Systems?
Adding elements of an array using two processor
int sum, A[ n] ; //shared variables
void main ( ){
int i ;
for (i=0; i scanf ("%d",&A[i] ); sum=0; // now create process to be executed 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 executed 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 last half of array is passed to processor P1 that adds them. For the meantime processor P0 adds the first half of array. The variable sum is locked to avoid inconsistency.
scanf ("%d",&A[i] );
sum=0;
// now create process to be executed 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 executed 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 last half of array is passed to processor P1 that adds them. For the meantime processor P0 adds the first half of array. The variable sum is locked to avoid inconsistency.
pebbles merchant
Translate each of the following sentences into predicate calculus, conceptual dependencies, and conceptual graphs: 1. Bill sold the book to the book store." 2. "John borrowed
Question : (a) "Resolution refers to the sharpness and clarity of an image" (i) Explain what you understand by the above statement. (ii) What is the difference between D
Draw the logic diagram of 16-bit ROM Array and explain its principle of operation. Ans: 16-bit ROM Array: A ROM that is read-only memory is an array of selectively closed
Why does IPV6 use separate extension headers? Explain. The extension headers in Ipv6 are utilized for economy and extensibility. Partitioning the datagram functionality in sepa
In the shared-memory programming model, tasks share a common address space, which they read and write asynchronously. Several mechanisms such as locks / semaphores may be used to c
Explain Open source software? Open Source Software is software for which the underlying programming code is available to the users so that they might be read it, make changes t
Illustrate the list of key differences to word processors The following is a list of key differences to word processors: - Most word processors force users to work on a doc
Describe ARP message format in brief. 0 8 16
Data packets: A data packet consists of the PID which is followed a 16-bit CRC and by 0-1023 bytes of data payload (up to 1024 in high speed and at most 8 at low speed) The
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