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.
Define data type and abstract data type comment upon the significant of both
What is an operating system? An operating system is system software which provides interface between hardware and user. The operating system gives the means for the proper uti
Q. What is the impact of overflow for binary numbers? An overflow is said to have happened when sum of two n digits number takes n+ 1 digits. This definition is perfectly appli
Machine Centred versus human Centred The discussion here is based on the difference in approach to the design of the work system when we prioritise either the needs of the mac
Q. Write a pseudo code to find sum of two functions? Let's write a pseudo code to find sum of two functions f(A) + f(B). In first algorithm we will not use locking. Process
How the at-user command serves mainly in lists? The AT USER-COMMAND event serves mostly to handle own function codes. In this case, you should make an individual interface wit
CONTROL SECTION: The control section directs the flow of traffic (operations) and data. Also it maintains order within the computer. The control section chooses one program sta
What is verilog case (1) ? wire [3:0] x; always @(...) begin case (1'b1) x[0]: SOMETHING1; x[1]: SOMETHING2; x[2]: SOMETHING3; x[3]: SOMETHING4; endcase
Explain Sequential sharing. Sequential sharing: In this technique of sharing, a file can be shared through only one program at a time, it is file accesses by P1 and P2 are
A series of keystrokes and mouse clicks that can be abbreviated into a one keystroke or mouse click.
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