operating-systemsynchronizationstarvation

Why Disabling Interrupts Synchronization Satisfies Bounded Waiting


Definition: Bounded waiting refers to a process P_i that keeps waiting forever to enter critical section (CS) while other processes P_j keep entering CS although P_i has shown interest to enter CS.

Now, I understand why lock variable mechanism is not bounded waiting because if a process entered a non-critical section, then another process might come and take CS, so a process might starve.

Algorithm:

NCS (Non-critical Section)
DISABLE INTERRUPTS
CS
ENABLE INTERRUPTS
NCS

Edit: no more details are given about schedulers, etc. The question is to get a glance whether this satisfies bounded waiting or not.

Question: can you please explain why disabled interrupts synchronization mechanism satisfies bounded waiting please (a process can not starve to enter CS as in lock variable mechanism)?


Solution

  • Your question has two contexts to consider:

    1. Are interrupt handlers entering the Critical Section?
    2. Is there an asynchronous scheduler involved?

    No,No As soon as P_i releases the CS, the release mechanism can accept P_j, thus starvation is averted.

    No,Yes Despite P_j's desire, once interrupts are released, the scheduler could be invoked, and decide that P_j is not to be executed next, so in at least a pathological case, could spend forever trying to enter the CS while others are selected.

    Yes,No As soon as P_i release the interrupt, any pending interrupts will execute immediately. If they are to enter the CS, they will first (otherwise the system has halted [*]), so with the right timing a set of interrupts could keep P_j starved forever.

    Yes,Yes Here, the starvation could happen for either of the reasons No,Yes or Yes,No.

    [*] - Interrupts have no a-priori way of deferring work, so any resources required to complete the interrupt handler must be available when the handler runs. The handlers context is effectively nested; and a nested context cannot wait for the completion of its superior context.