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 flowchart, Define Flowchart. A  process  of  expressing  an  alg...

Define Flowchart. A  process  of  expressing  an  algorithm  by  a  collection  of  linked  geometric  shapes   containing explanations of the algorithm's steps.

Correct cluster, For each of the three datasets (data1.txt, data2.txt, and ...

For each of the three datasets (data1.txt, data2.txt, and data3.txt in bnhw2q2.zip), cluster the data using k-means in Matlab, with k=2, 3, 4 and 5 using the provided Matlab script

What is a switchboard, What is a switchboard A switchboard is only a f...

What is a switchboard A switchboard is only a form with command button that open other switchboard or perform tasks like opening forms and printing reports. Switchboard is a t

Explain the disadvantages off-the-shelf, Explain the disadvantages Off-the...

Explain the disadvantages Off-the-shelf -  can be over-complex since it tries to cover as many characteristics as possible (for example most users of Word only utilise about

Learning abilities of perceptrons - ann, Learning Abilities of Perceptrons ...

Learning Abilities of Perceptrons - Artificial intelligence Computational learning theory is the study of what concepts specific learning schemes (representation and method) ca

Determine a program that is in execution, Determine a program that is in ex...

Determine a program that is in execution is known as Program in execution is known as Process

Basic concept of data parallelism, Basic Concept of Data Parallelism T...

Basic Concept of Data Parallelism Thinking the condition where the same problem of submission of „electricity bill? is Handled as follows: Again, three are counters. Howeve

Difference between absolute and relative path, What is the difference betwe...

What is the difference between absolute and relative path name of a file? Absolute path name: This is listing of the directories and files from the root directory to the i

Which datatype cannot be used to define parameters, Which datatype cannot b...

Which datatype cannot be used to define parameters. Type F datatype is not used to explain parameters.

Variables and quantifiers - first-order logic, Variables and Quantifiers: ...

Variables and Quantifiers: Now we have to diagnose now that if we wanted to say that there is a meal at the Red Lion which costs only 3 pounds, is well sayed. Rather thenif we

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