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.
Why pointer variable sometimes desirable to pass a pointer to a function as an argument? Frequently, a called function needs to make changes to objects declared in the calling
Cache Memories - computer architecture: Speed of the primary memory is very low in comparison with the speed of processor For well performance, the processor can't spend
DOS is not a RTOS (real time Operating system), though MS DOS can be used with certain APIs to attain the RTOS functionality. For example, the RT Kernel (Real Time Kernel) which ca
The features are needed to implement top down parsing are? Ans. Source string marker, Prediction making mechanism and also matching and backtracking mechanism features are need
Input a list of positive numbers, terminated by 0, into an array Numbers. Then display the array and the largest and smallest number in it.
The PVM system supports functional and data decomposition model of parallel programming. It attaches with C, C++, and FORTRAN. The C and C++ language bindings for the PVM user inte
Determine about the Security Policy In the United States, the government has a separate organisation looking after the security measures and providing guidelines to all departm
Objectives of object oriented analysis After going through this unit, you should be able to: define the concepts of the objects in the system; express desired syste
State the data flow diagramming conpects The approach to data flow diagramming is as follows: Create a data flow diagram for each of major outputs of system Work ba
Case Study - A taxi company has 200 taxies. The company provides its services to all the nine districts in Mauritius, about 20 taxies per district. A taxi is normally attached to
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