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 handlers classification, Handlers Classification In 1977, Wolfg...

Handlers Classification In 1977, Wolfgang Handler suggested a complex notation for representing the pipelining and parallelism of computers. Handler's categorization addresses

Illustrate what is a ion pair energy, Q. Illustrate what is a ion pair ener...

Q. Illustrate what is a ion pair energy? Answer:- Ion energy contains electric charges called protons (+) and neutrons (0) and electrons (-) charges. It's present in an at

What is garbage collection and what is it used for, In computer science, ga...

In computer science, garbage collection (GC) is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by

Registered ports, A) What does this file have? Where was the information in...

A) What does this file have? Where was the information in this file acquired from? What is the information in this file used for? B)  What is the range for popular ports? What i

Feasebility study, what are the feasibility study of online result manageme...

what are the feasibility study of online result management system?

Define wait protocol, Q. Define Wait protocol? The wait protocol is use...

Q. Define Wait protocol? The wait protocol is used for resolving conflicts that arise due to some multiprocessors requiring same resource. There are 2 kinds of wait protocols:

Social media strategy design, For this phase of the project you are require...

For this phase of the project you are required to formulate a social media strategy for a product/service/business/concept/charity...etc. the strategy can include technologies such

Explain garbage collection, Explain Garbage collection In this method ...

Explain Garbage collection In this method two passes are made over the memory to identify new areas. In the first pass it traverses all pointers pointing to allocated areas an

Illustrate role of world wide web in field of e-commerce, Illustrate the ro...

Illustrate the role of World Wide Web into the field of e-commerce. In the 1990 year, the advent of the World Wide Web upon the Internet represented a turning point into e-com

Versions of small computer systems interface, Q. Versions of small computer...

Q. Versions of small computer systems interface? SCSI-1 calls for a cable with 8 data wires plus one for parity. SCSI-2 allows use of multiple cables to support 16- or

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