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

Define device interface, Define device interface. The buffer registers ...

Define device interface. The buffer registers DATAIN and DATAOUT and the status flags SIN and SOUT are part of circuitry commonly called as a device interface.

Write a pseudocode for a program, Write a pseudocode for a program that acc...

Write a pseudocode for a program that accepts 10 numbers from a user and calculates the sum of all the numbers entered that are greater than or equal to 10.

Convert the following into sop form, Q. Convert the following into SOP form...

Q. Convert the following into SOP form   1. (A+B) (B'+C) (A'+ C) 2. (A+C) (AB'+AC) (A'C'+B) 3. (A'+B') (C'+B)   Q.Convert the following into POS form   1. WYZ + XYZ + W'X'

C++, What are virtual Functions

What are virtual Functions

What are the advantages of store program control, What are the Advantages o...

What are the Advantages of store program control (I) Easy to maintain (II) Easy to control (III) Wide range of services can be provided to customers (IV) Flexible

Command mode to insertion mode using vi editor, How to enter from command m...

How to enter from command mode to insertion mode using Vi Editor? Ans) There are various commands that put the VI editor into insert mode. The most usually used commands to get

Android mobile application, Students are needed to work in group of 3 and m...

Students are needed to work in group of 3 and make an Android mobile application falling under the following categories: Multimedia o    Eg: Camera app, mp3 player, ga

Analog-to-digital conversion process, A stationary random displacement sign...

A stationary random displacement signal was digitised at 64 samples a second and analysed to obtain an auto-spectral density.  The signal was calibrated in mm units.  The frame siz

What is internet routing hierarchy, Q. What is Internet Routing Hierarchy? ...

Q. What is Internet Routing Hierarchy? So how do packets find their way across Internet? Does every computer connected to Internet know where other computers are? Do packets ba

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