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

Limits of traditional payment instruments and overcome, What are the restri...

What are the restrictions of traditional payment instruments? How are such restrictions overcome by electronic payment systems? The restrictions of traditional payment system a

What are sections, Layout pages, can describe sections, which can then be o...

Layout pages, can describe sections, which can then be overridden by particular views making use of the layout. Major and overriding sections is optional.

Program that will blink as led, Take the last two digits of your UTCID. Thi...

Take the last two digits of your UTCID. This is your duty cycle in percent. If your duty cycle is less than 10%, add 30 to your number. Create an assembly program that runs on t

Communication between memory and the processor, How are instructions sent b...

How are instructions sent between memory and the processor? Both the instruction pointer (IP) and program counter (PC) utilized to holds the memory address of the next inst

Predictive modelling power, Another useful feature of an experts system ...

Another useful feature of an experts system is its predicative modelling power. The system can act as an information processing theory or model of problem solving in th

What are kinds of processors, Processors can broadly be seperated into the ...

Processors can broadly be seperated into the categories of: CISC, RISC, hybrid, and special purpose.

What is stack, Stack is a portion of RAM used for saving the content of Pro...

Stack is a portion of RAM used for saving the content of Program Counter and common purpose registers. LIFO stacks, also called as "push down" stacks, are the conceptually easi

Dos function calls, INT 21H supports about 100 different functions. A funct...

INT 21H supports about 100 different functions. A function is recognised by putting the function number in AH register. For illustration if we want to call function number 01 then

How to detect overflow condition, How to detect overflow condition An o...

How to detect overflow condition An overflow condition can be notice by observing the carry into the sign bit position and the carry out of sign bit position. If this carries a

Define peripheral, Define peripheral. Devices that are under the direct...

Define peripheral. Devices that are under the direct control of computer are said to be linked online. These devices are intended to read information into or out of the memory

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