Admit readers against a fixed pool capacity and turn the remaining slots into an admit, hold, or shed remediation action.

remaining capacity The reader pool capacity is modeled with a scalar counter, so the remaining slots stay deterministic and free of semaphore identity while driving the remediation action.

Reader Pool Remediation Report

readers
ReaderPoolRemediationReport.cs
Replay: real traced execution (multi-file project)
using System;

class Program
{
    static void Main()
    {
        int readers = 1;
        int capacity = 3;
        int admitted = readers;
        if (admitted > capacity)
        {
            admitted = capacity;
        }
        int remaining = capacity - admitted;

        string action;
        if (remaining >= 2)
        {
            action = "admit";
        }
        else if (remaining == 1)
        {
            action = "hold";
        }
        else
        {
            action = "shed";
        }

        Console.WriteLine("readers=" + readers + " admitted=" + admitted + " remaining=" + remaining + " " + action);
    }
}
using System;

class Program
{
    static void Main()
    {
        int readers = 2;
        int capacity = 3;
        int admitted = readers;
        if (admitted > capacity)
        {
            admitted = capacity;
        }
        int remaining = capacity - admitted;

        string action;
        if (remaining >= 2)
        {
            action = "admit";
        }
        else if (remaining == 1)
        {
            action = "hold";
        }
        else
        {
            action = "shed";
        }

        Console.WriteLine("readers=" + readers + " admitted=" + admitted + " remaining=" + remaining + " " + action);
    }
}
using System;

class Program
{
    static void Main()
    {
        int readers = 4;
        int capacity = 3;
        int admitted = readers;
        if (admitted > capacity)
        {
            admitted = capacity;
        }
        int remaining = capacity - admitted;

        string action;
        if (remaining >= 2)
        {
            action = "admit";
        }
        else if (remaining == 1)
        {
            action = "hold";
        }
        else
        {
            action = "shed";
        }

        Console.WriteLine("readers=" + readers + " admitted=" + admitted + " remaining=" + remaining + " " + action);
    }
}
  1. readers ← 1, capacity ← 3, admitted ← 1, remaining ← 2

    4{5    static void Main()6    {7        int readers→ 1 = 1; //@readers=2, 48        int capacity→ 3 = 3;9        int admitted→ 1 = readers1;10        if (admitted > capacity)11        {12            admitted = capacity;13        }14        int remaining→ 2 = capacity3 - admitted1;1516        string action;17        if (remaining >= 2)
  2. action ← admit

    16string action;17if (remaining2 >= 2)18{19    action→ admit = "admit";20}
  3. Console.WriteLine("readers=" + readers + " admitted=" + admitted + " r…

    30    Console.WriteLine("readers=" + readers1 + " admitted=" + admitted1 + " remaining=" + remaining2 + " " + actionadmit);31}
    outputreaders=1 admitted=1 remaining=2 admit
  1. readers ← 2, capacity ← 3, admitted ← 2, remaining ← 1

    4{5    static void Main()6    {7        int readers→ 2 = 2;8        int capacity→ 3 = 3;9        int admitted→ 2 = readers2;10        if (admitted > capacity)11        {12            admitted = capacity;13        }14        int remaining→ 1 = capacity3 - admitted2;1516        string action;17        if (remaining >= 2)
  2. action ← hold

    20}21else if (remaining1 == 1)22{23    action→ hold = "hold";24}
  3. Console.WriteLine("readers=" + readers + " admitted=" + admitted + " r…

    30    Console.WriteLine("readers=" + readers2 + " admitted=" + admitted2 + " remaining=" + remaining1 + " " + actionhold);31}
    outputreaders=2 admitted=2 remaining=1 hold
  1. readers ← 4, capacity ← 3, admitted ← 4

    4{5    static void Main()6    {7        int readers→ 4 = 4;8        int capacity→ 3 = 3;9        int admitted→ 4 = readers4;10        if (admitted > capacity)
  2. admitted ← 3

    9int admitted = readers;10if (admitted4 > capacity3)11{12    admitted→ 3 = capacity3;13}
  3. remaining ← 0

    13}14int remaining→ 0 = capacity3 - admitted3;1516string action;17if (remaining >= 2)
  4. action ← shed

    24}25else26{27    action→ shed = "shed";28}
  5. Console.WriteLine("readers=" + readers + " admitted=" + admitted + " r…

    30    Console.WriteLine("readers=" + readers4 + " admitted=" + admitted3 + " remaining=" + remaining0 + " " + actionshed);31}
    outputreaders=4 admitted=3 remaining=0 shed