Turn the number of waiters behind a held guard into an enter, backoff, or page remediation action.

Semaphore Guard Remediation Report

SemaphoreGuardRemediationReport.cs
using System;

class Program
{
    static void Main()
    {
        int waiters = ;
        int guardLimit = 2;
        int acquired = 1;

        string action;
        if (waiters == 0)
        {
            action = "enter";
        }
        else if (waiters <= guardLimit)
        {
            action = "backoff";
        }
        else
        {
            action = "page";
        }

        Console.WriteLine("waiters=" + waiters + " acquired=" + acquired + " " + action);
    }
}
using System;

class Program
{
    static void Main()
    {
        int waiters = ;
        int guardLimit = 2;
        int acquired = 1;

        string action;
        if (waiters == 0)
        {
            action = "enter";
        }
        else if (waiters <= guardLimit)
        {
            action = "backoff";
        }
        else
        {
            action = "page";
        }

        Console.WriteLine("waiters=" + waiters + " acquired=" + acquired + " " + action);
    }
}
using System;

class Program
{
    static void Main()
    {
        int waiters = ;
        int guardLimit = 2;
        int acquired = 1;

        string action;
        if (waiters == 0)
        {
            action = "enter";
        }
        else if (waiters <= guardLimit)
        {
            action = "backoff";
        }
        else
        {
            action = "page";
        }

        Console.WriteLine("waiters=" + waiters + " acquired=" + acquired + " " + action);
    }
}
guard contention The waiter count behind a held guard is kept as a scalar, so the remediation action stays deterministic and never depends on semaphore identity or scheduler timing.