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

Explain the feasibility study, Explain the Feasibility Study This inclu...

Explain the Feasibility Study This includes writing a report to convince management of the merits of adopting proposed new system. Some features of the study comprise: T

Explain the storage class auto, Explain The Storage Class auto The Stor...

Explain The Storage Class auto The Storage Class auto : Variables declared within function bodies are automatic by default. Thus, automatic is the most common of the four stora

Explain collaboration on task and event management, What is difference betw...

What is difference between collaboration on task and event management? Web-based task management application let the user handle the multiple pieces and parts of large projects

What is clock gating, What is Clock Gating? Clock gating is one of the...

What is Clock Gating? Clock gating is one of the power-saving methods used on several synchronous circuits with the Pentium four processors. To save power, clock gating consid

What are the important tools of a three-tier client server, What are the im...

What are the important tools of a three-tier client server? In a three-tier or multi-tier environment, there the client implements the presentation logic or the client. The bus

#microprocessor, Program to transfer 10 byte of data from DMS to EMS using ...

Program to transfer 10 byte of data from DMS to EMS using 8086 instructions

Define frequency division - application of flip flops, Define Frequency Div...

Define Frequency Division - Application of Flip Flop? When the pulse waveform is applied to the clock input of a J-K flip-flop that is connected to toggle, the Q output is a s

Determine about the security methods, Determine about the Security methods ...

Determine about the Security methods Security methods also protect information from accidental or intentional modification, manipulation or destruction. Most security experts o

How to define a filename in dos, Q. How to define a Filename in DOS? Ea...

Q. How to define a Filename in DOS? Each file is given a name so that it can be referred to later. This name is termed as Filename. The filename in DOS can be up to eight alpha

C programming, There is a pebble merchant. He sells the pebbles, that are u...

There is a pebble merchant. He sells the pebbles, that are used for shining the floor. His main duty is to take the length of the room’s sides. But he sometimes mistakes doing that

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