Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Network & Security Expert

Shared Programming Using Library Routines

The most well-liked of them is the use of combo function called fork() and join(). Fork() function is used to make a new child process. By calling join() function parent process waits the terminations of the child process to obtain the desired result.

Example 11: Consider the following set of statements

Process A                                 Process B

:                                                      :

fork B ;                                                      :

:                                                                :

join B;                                                      end B;

In the above set of statements process A makes a child process B by the statement fork B. Then A and B continue their computations independently up to  A reaches the join statement, At this stage, if B is already ended, then A continues implementing the next statement otherwise it waits for B to finish.

 In the shared memory model, a common trouble is to synchronize the processes. It may be possible that more than one process is trying to concurrently modify the similar variable. To solve this problem many synchronization mechanism like test_and_set, monitors and semaphores have been used. We shall not go into the details of these mechanisms. Quite, we shall represent them by a pair of two processes called lock and unlock. Whenever a process P locks a common variable, then only P can use that variable. Other simultaneous processes have to wait for the common variable until P calls the unlock on that variable. Let us see the effect of locking on the output of a program when we do not use lock and when we use lock.

Example 12

Let us write a pseudocode to find sum of the two functions f(A) + f(B). In the first algorithm we shall 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 implements the statement sum = sum + f (A) and writes the results into main memory followed by the computation of sum by process B, then we get the right result. But consider the case when B implements the statement sum = sum + f (B) before process A could write result into the main memory. Then the sum contains only f(B) which is not right. To avoid such inconsistencies, 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 whenever a process gets the sum variable, it locks it so that no other process can access that variable which makes sure the consistency in results.

Computer Network & Security, Computer Science

  • Category:- Computer Network & Security
  • Reference No.:- M9525913

Have any Question?


Related Questions in Computer Network & Security

1srin response to nmap -n -sn localhost what kind of

1. SR In response to "nmap -n -sn localhost": What kind of information did the nmap scan results show you, specifically? 2. FIB What does the "-sn" option do in nmap? ping scan -disable port scan 3. SR How does the "-sn" ...

Two countries australia and france have their interest

Two Countries Australia and France have their interest rates to be 8% and 2 %, respectively. If their currencies trade according to 2 Australian $s buy one euro in the spot market, what will their future spot rate be in ...

Consider the following series of paymentsyear 0 20year 1

Consider the following series of payments: Year 0: 20 Year 1: 30 Year 2: 40 Year 3: 10 Year 4: 5 Using an interest rate of 10%: a. What is the present value of this series of payments? b. What is the future value of this ...

If a router is attached to a network with a base ip address

If a router is attached to a network with a base IP address of 198.10.0.0/20 and receives a packet addressed to 198.10.10.144, answer the following questions: What is the network mask used by the router? (in dotted decim ...

Advanced network design assessment - human factors in

Advanced Network Design Assessment - Human factors in network analysis and design Purpose of the assessment - This assignment is designed to assess students' knowledge and skills related to the following learning outcome ...

Objectivespart 1 researching network attacks- research

Objectives Part 1: Researching Network Attacks - Research network attacks that have occurred. - Select a network attack and develop a report for presentation to the class. Part 2: Researching Network Security Audit Tools ...

Advanced network design assessment - human factors in

Advanced Network Design Assessment - Human factors in network analysis and design Purpose of the assessment - This assignment is designed to assess students' knowledge and skills related to the following learning outcome ...

Question a signal travels through an amplifier and its

Question : A signal travels through an amplifier, and its power increased and becomes doubled. Then calculate amplification for this condition 2 Discuss about the TCP/IP PROTOCOL SUITE and Principles of Protocol Layering ...

The abstract should not be more than 250 words describe

The abstract should not be more than 250 words. Describe your project, focusing on research questions and research method for next stage of the project. 1. Introduction [The introduction should describe what the project ...

What is the difference between a positive economic

What is the difference between a positive economic statement and a normative one.

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As