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

C programming, write a program to find the area under the curve y=f(x) betw...

write a program to find the area under the curve y=f(x) between x=a and x=b,integrate y=f(x) between the limits of a and b

Calculating block size - computer architecture, Calculating Block Size: ...

Calculating Block Size: B A unit of associatively -one tag for B A words B T unit of transfer-B T words to/from primary memory as a unit             One valid bit for

State the advantages off-the-shelf, State the advantages Off-the-shelf ...

State the advantages Off-the-shelf -  tends to be less expensive as development costs can be spread over many users -  can be more sophisticated as large sales bring in c

Compiler software difficulty, IA-64 instead depends on the compiler for thi...

IA-64 instead depends on the compiler for this task. Even before the program is fed into the CPU, the compiler studies the code and makes the similar sorts of decisions that would

Analysis of amdahls law, The outcomes of analysis of Amdahl's law are: 1...

The outcomes of analysis of Amdahl's law are: 1) To optimize the performance of parallel computers, modified compilers need to be developed which should aim to decrease the numb

Unit test an mvc application, Is it possible to unit test an MVC applicatio...

Is it possible to unit test an MVC application without running the controllers in an ASP.NET process? Ans) Yes, all the features in an asp.net MVC application are interface ba

Develop a system to store change logs , The ?rst task in the project is to ...

The ?rst task in the project is to develop a sane system to store change logs and versions of ?les. The simplest approach is to create a "dot" directory in the location of the ?le

Sosail studies, whitch goods did the new england colonies exportto england ...

whitch goods did the new england colonies exportto england and what did they get in return

OR, importance of duality concep? Article Source: http://EzineArticles.co...

importance of duality concep? Article Source: http://EzineArticles.com/4133733

2 way staircase switch-truth table logic equation & circuit, A staircase li...

A staircase light is controlled by two switches one at the top of the stairs and another at the bottom of stairs a. Make a truth table for this system. b. Write the lo

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