How does priority ceiling protocol works
<p>In the below scenario how the priority of the task t1 will change when the locks are released, assuming Sem_Take() and Sem_Give() are lock and release method.</p>

<p>I understand that using priority ceiling protocol raises the priority of the task as soon as a resource is locked, but what happens when the lock is released.</p>

<pre><code>    void t1()//Initial priority 2
{
    int a;
    Sem_take(S1); //priority ceiling for S1 is 4
    .
    .
    Sem_take(S2);//priority ceiling for S2 is 6
    .
    .
    Sem_Give(S1);
    .//What is the priority at this line?
    .
    Sem_Give(s2);
    .//What is the priority at this line?
    .
}
</code></pre>

<p>Also in the above scenario the semaphore lock and release are mismatched that is it erroneous but a program might mistakenly do that, then in this case how the PCP will work. </p>