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.
The alignment of a type 'c' field in a report is? ? Left Aligned.
ENCTYPE="application/x-www-form-urlencoded" and in its place use ENCTYPE="text/plain". The subsequent illustration displays a general form which includes some of the commo
What is common control switching system? Explain. Common Control Switching System: It is a functional block diagram of a common control switching system is demonstrated in figu
Q. Explain about Associative Memory Organisations? The associative memory is arranged in w words with b bits per word. In w x b array, every bit is known as a cell. Every cell
Convert the octal number 7401 to Binary. Ans. Octal number 7401 to Binary conversion: Every octal digit represents 3 binary digits. To change an octal number to binary number,
Give some examples of malicious data. In May 2002, the Norton Anti-Virus software for Windows operating systems detects about 61000 malicious programs. Some of them are named
Application layer: It's the topmost layer in OSI model, which allows the user to access network. This layer provides user interface for network applications like remote login, Wor
Write shorts notes on Sliding Window Protocol To acquire high throughput rates, protocols employ a flow control technique termed as sliding window. Both, the sender and receive
what is cardinality ratio?
Consider the ReadRear Java method (a) Illustrate pictures that explain the data structure every time a checkpoint is reached for the problems of sizes one, two, three and four s
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