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

Running time - metrics for performance evaluation, Running Time - Metrics f...

Running Time - Metrics for performance evaluation: Running time is amount of time consumed in execution of an algorithm for a provided input on N-processor based parallel comp

Multi-layer network architectures, Multi-Layer Network Architectures - Arti...

Multi-Layer Network Architectures - Artificial intelligence: Perceptrons have restricted scope in the type of concepts they may learn - they may just learn linearly separable f

Use of typewriters for multiple copies, Use of Typewriters for Multiple Cop...

Use of Typewriters for Multiple Copies : Offices frequently require copies of various letters and documents. The simplest method is to make the copies at the same time along with

How is the command suppress-dialog useful, How is the command Suppress-Dial...

How is the command Suppress-Dialog useful? Suppressing whole screens is possible using this command.  This command permits us to perform screen processing "in the background".

Explain simple network management protocol, Explain SNMP (simple network ma...

Explain SNMP (simple network management protocol). Once SNMP is used the management station sends a request to an agent asking this for commanding or information this to update

Parallel edge or self loop of the total number of edges, A graph with n ver...

A graph with n vertices will definitely have a parallel edge or self loop of the total number of edges are More than n(n-1)/2

Explain the page stealer and the fault handler, How the Kernel handles both...

How the Kernel handles both the page stealer and the fault handler? The page stealer and the fault handler thrash because of the shortage of the memory. If the sum of the worki

What is the benefit of report wizard over an auto report, What is the benef...

What is the benefit of Report Wizard over an Auto Report? It takes a little more work to make a report with the report wizard than with the Auto Report but you have a lot more

Posix threads and mutex, The objective of this practical assignment is to u...

The objective of this practical assignment is to use the POSIX environment to write a program that simulates the supply and demand between three processes: warehouse, factory and r

What do you understand by www, What do you understand by WWW? WWW (Wo...

What do you understand by WWW? WWW (World Wide Web): It is an architectural framework for accessing linked documents outspread over thousands of machines the whole world.

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