Show the programmes for parallel systems, Computer Engineering

Assignment Help:

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.


Related Discussions:- Show the programmes for parallel systems

Explain clearly the difference between j-cuts and l-cuts, Question: (a)...

Question: (a) Explain clearly the difference between J-cuts and L-Cuts. (b) What is the function of the rate stretch tool? (c) What's the difference between an Image Matt

Illustrate the execute cycle, Q. Illustrate the Execute Cycle? The fetc...

Q. Illustrate the Execute Cycle? The fetch and indirect cycles include a small, fixed sequence of micro-operations. Every one of these cycles has fixed sequence of micro-operat

Explain session layer of osi model, Explain Session Layer of OSI Model. ...

Explain Session Layer of OSI Model. The session layer manages, establishes and terminates communication sessions. Communication sessions contain service of requests and serv

What are the limitations of traditional payment instruments, What are the l...

What are the limitations of traditional payment instruments? The limitations of traditional payment system are that they take a lot of time.  These systems needs manual work to

Evaluate bandwidth of disk drive, Q. Evaluate Bandwidth of disk drive? ...

Q. Evaluate Bandwidth of disk drive? Bandwidth:  Bandwidth can be measured in bytes per second. Sustained bandwidth is the average data rate at the time of a large transfer w

Fundamental components of a CPU, Q. Fundamental components of a CPU? Th...

Q. Fundamental components of a CPU? The two fundamental components of a CPU are control unit and arithmetic and logic unit. The control unit of CPU selects and interprets progr

Build a program to maintain his personal account, Aim: Build a program or a...

Aim: Build a program or application which gives an interface to the user to maintain his personal account for E-mails & should be able to work on the following applications. Des

The types of parameters in the function modules, What are the types of para...

What are the types of parameters in the function modules? In general, function module can have four types of parameters: EXPORTING : for passing data to the called function

What are advantages and disadvantages of using eeprom, What are advantages ...

What are advantages and disadvantages of using EEPROM? The benefits are that EEPROM do not have to be removed for erasure. Also it is possible to delete the cell contents selec

Big – endian and little- endian representations, Explain Big - Endian and L...

Explain Big - Endian and Little- Endian representations Ans: The Big- endian is used where lower byte addresses are used for the more significant bytes (leftmost bytes) of the

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

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!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd