Write a pseudo code to find sum of two functions, Computer Engineering

Assignment Help:

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 A                                Process B

 sum = 0                                           :

    :                                                   :

  fork B                                     sum = sum+ f(B)

   :                                                   :

 sum = sum + f(A)                         end B

    :

    join B   

   :

 end A

If process A executes statement sum = sum + f(A) in addition writes results in main memory followed by computation of sum by process B then we attain correct result however consider case when B executes statement sum = sum + f(B) before process A can write result in the main memory. Then sum comprises only f(B) that is incorrect. To avoid such variation we use locking.  

Process A                                Process B

 sum = 0                                           :

    :                                                   :

    :                                                  lock sum               

  fork B                                     sum = sum + f(B)

   :                                                   unlock sum

  lock sum                                        :

 sum = sum + f(A)                         end B

unlock sum 

   :

    join B   

   :

 end A

In this case every time a process obtains sum variable it locks it sothat no other process can access that particular variable that guarantees consistency in results.


Related Discussions:- Write a pseudo code to find sum of two functions

What are the different auto reports available in access, What are the diffe...

What are the different auto reports available in Access? The dissimilar auto reports available in Access are: Columnar AutoReport: makes a report where each row is shown ver

File history.d1 contains a brief history of computing, File History.d1 cont...

File History.d1 contains a brief history of computing. There are no indentations in this file. Write a program to read this file, inserting five blank spaces at the beginning of ea

Expression for boolean function in standard POSform, Write the expression f...

Write the expression for Boolean function for F (A, B, C) = ∑m (1,4,5,6,7) in standard POS form.                                   Ans: f (A,B,C )= ΣM (1,4,5,6,7) in standard POS

Spmd model for programming, Q. SPMD model for programming? A normal ass...

Q. SPMD model for programming? A normal assumption was that it must be possible and not too hard to capture the SPMD model for programming MIMD computers in data parallel langu

Bubbling the pipeline - computer architecture, Bubbling the Pipeline: B...

Bubbling the Pipeline: Bubbling the pipeline (also known as a pipeline break or pipeline stall) is a technique for preventing, structural, data and branch hazards from taking p

State about the harvard mark I and the bug, Harvard mark i and the bug ...

Harvard mark i and the bug The next important effort towards devising an electromechanical computer was done at the harvard University, jointly sponsored by the Department of U

Two methods of copying a information document, There are basically two meth...

There are basically two methods of copying: Photocopying This is a modified development of photography. It is quite expensive and slow and is not often used for routine rep

The functions islower() and tolower(), Distinguish among the functions islo...

Distinguish among the functions islower() and tolower().   islower( ) and tolower( ): islower(c) is a character testing function described  in ctype.h header file. This

Why we need number systems, Q. Why we need number systems? Number syste...

Q. Why we need number systems? Number system is used to signify information in quantitative form. Some of the general number systems are octal, decimal, hexadecimal and binary.

Period and space tradeoffs - artificial intelligence, Period and Space Trad...

Period and Space Tradeoffs - artificial intelligence: In practice, you are going to stop your agent for long term using in searching goal at some stage if it has not found a s

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