Problem:
Question- SWAP (A,B) swaps the contents of the variables A and B in one machine instruction. Show how we can use this instruction to solve the critical section problem. The solution you propose may lead to starvation; i.e., two processes cooperate so that the third process will never get a chance to enter the critical section. Show how you can avoid the starvation problem.
Please describe the code of swapping two numbers.