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

Interpolation algorithm, Design two matlab algorithms for enlarging the 256...

Design two matlab algorithms for enlarging the 256x256 images into 512x512 images by using bilinear and bicubic interpolations   a)  Evaluate the interpolated images with the

Perform binary addition and subtraction on two numbers, Q Develop a menu ...

Q Develop a menu driven program to perform Binary addition and subtraction on two numbers that are inputted. Check that entered numbers are in base 2 or not else error messag

Explain the typical functions of operating systems, List the typical functi...

List the typical functions of operating systems. Classical functions of operating system are given as: (1) Process management: A process is a program throughout execution.

Define the method of implementation, Define the method of Implementation ...

Define the method of Implementation Once "final" system has been designed it is then essential to put together the software and hardware and introduce the new system. There ar

What is blocking probability, What is blocking probability? Blocking ...

What is blocking probability? Blocking Probability: The blocking probability P is described as the probability like all the servers in system are busy. If all the servers ar

Explain the functional units of a basic computer, Question 1 Explain th...

Question 1 Explain the functional units of a basic computer with a neat diagram 2 What do you mean by addressing modes? List the different types of addressing modes 3 Exp

Short notes on model primitives in director mx 2004, Question: (a) Prep...

Question: (a) Prepare short notes on the model primitives in Director MX 2004. (b) Therefore using the box primitive write codes to prepare a new model resource of length 50

Platform assignment system, Platform assignment system for the trains in a ...

Platform assignment system for the trains in a railway station cpp program

Time Complexity, how to determiner time complexity of any given polynomial ...

how to determiner time complexity of any given polynomial in data structure?

Show the properties of frame tag, Q. Show the properties of Frame Tag? ...

Q. Show the properties of Frame Tag? This tag is used for placing an HTML file in the frame created. We should now tell browser what to put in every frame.

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