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

Call the masm procedure, Assignment:  write a C program and a MASM procedur...

Assignment:  write a C program and a MASM procedure.  The C program calls the MASM procedure to perform letter case conversion. Text sections covered:  12.1 to 12.3.1 Write a

What is the role of mar and mdr, What is the role of MAR and MDR? The ...

What is the role of MAR and MDR? The MAR (memory address register) is used to hold the address of the location to or from which data are to be transferred and the MDR(memory d

How to copy several files in one stroke, Q. How to copy several files in on...

Q. How to copy several files in one stroke? The COPY command can also be used to copy several files in one stroke by using wildcards. For example, consider the following comman

Explain complete binary tree, Complete Binary tree A complete binary tr...

Complete Binary tree A complete binary tree can be described as a binary tree whose non leaf nodes have nonempty left and right sub tree and all leaves are at the similar level

Explain about cathode ray tubes, Q. Explain about Cathode Ray Tubes? Ca...

Q. Explain about Cathode Ray Tubes? Cathode ray tube is the major technology on that televisions and monitors have been based.  CRT is a partially evacuated glass tube which is

Explain relative addressing scheme, Q. Explain Relative Addressing Scheme? ...

Q. Explain Relative Addressing Scheme? In this addressing technique the register R is the program counter (PC) which contains the address of current instruction being executed.

What do you understand by www, What do you understand by WWW? WWW (Wo...

What do you understand by WWW? WWW (World Wide Web): It is an architectural framework for accessing linked documents outspread over thousands of machines the whole world.

Convert number to hexadecimal and decimal, Perform the following calculatio...

Perform the following calculations assuming that all numbers are stored in 16-bit registers as 2's complement binary numbers with no overflow provision. Convert each of the numbers

Define process, Define Process. Process: It is a program in executi...

Define Process. Process: It is a program in execution; process execution should progress into sequential fashion. Process contains: program counter stack dat

Create a social network application, A software development company wants t...

A software development company wants to create a social network application where users can post brief audio messages giving their thoughts. Each user of the application will ha

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