title: Process Synchronisation using semaphores
body: <p>Here is the problem.
  I want two processes to occur alternatively, the complete problem is here.</p>
  
  <p>Q. In a system ther are two processes named A and B.When the system starts,the process A executes twice then process B executes once.The Process B cannot execute until process A has executed twice. Once Process A haas executed it can not execute again until process B has executed. The restriction mentioned above allows the process A and B to execute in the following manner.</p>
  
  <p>AABAABAAB...</p>
  
  <p>Write the pseudocode for Process A and B using counting semaphore to achieve the desired synchronisation.</p>
  
  <p>Here is my attemp for this.</p>
  
  <p>Solution:</p>
  
  <p>Process A</p>
  
  <pre><code>var a=1,b=0,i;
  begin
  repeat
      wait(a);
      for(i=0;i&lt;2;i++)
      printf("A");  // conidering this is what process a does.
      signal(b);
  forever
  end
  </code></pre>
  
  <p>Process B</p>
  
  <pre><code>begin
  repeat
      wait(b);
      printf("B"); //considering this is what process B does.
      signal(a);
  forever
  end
  </code></pre>
  
  <p>Is this correct?</p>