# Priority Queue with Aging Scheduler AI Agent Connect

> A deterministic scheduler that manages task execution using priority-based queues with an anti-starvation aging mechanism.

## Overview
- **Category:** scheduling
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_8seeOmc9dFMz5moubXgUYBxRi3r5Lezr93V4Skhv/ai-agent-connect
- **Tags:** priority-queue, aging, starvation-prevention, task-management, deterministic

## Description

This MCP server provides advanced scheduling capabilities for managing task queues. It uses a deterministic priority-based approach enhanced by an aging mechanism to prevent task starvation. By increasing a task's effective priority as it waits, the system ensures that even low-priority tasks are eventually executed. You can use `simulate_scheduling` to run full simulations, `get_task_by_id` to retrieve specific performance metrics, and `analyze_starvation_risk` to evaluate if your configuration is causing delays. It is designed to help developers analyze wait times, turnaround times, and throughput in complex task environments.

## Tools

### analyze_starvation_risk
Evaluates a set of task wait times to determine if the current scheduling configuration is causing significant starvation

### get_task_by_id
Retrieves specific metric details for a single task from a previously generated simulation

### simulate_scheduling
Executes a full scheduling simulation based on a specific set of tasks and environmental parameters

## Prompt Examples

**Prompt:** 
```
Run a simulation with 3 tasks: ID 'A' (priority 50, arrival 0, execution 100), ID 'B' (priority 10, arrival 0, execution 200), and ID 'C' (priority 80, arrival 10, execution 50). Use an aging rate of 0.5 and 1 agent.
```

**Response:** 
```
The simulation completed with task C executing first, followed by task A, and then task B. The average wait time was 45ms and throughput was 0.015 tasks/ms.
```

**Prompt:** 
```
Check if my current simulation results show any starvation risk using a wait time list of [10, 12, 15, 11, 100] and an average wait of 29.5.
```

**Response:** 
```
The starvation risk is High because the task with a wait time of 100 exceeds ten times the average wait time.
```

**Prompt:** 
```
What were the specific metrics for task 'task_001' in my last simulation?
```

**Response:** 
```
Task 'task_001' had a wait time of 50ms, a turnaround time of 150ms, a response time of 50ms, and a normalized turnaround of 1.5.
```

## Frequently Asked Questions

**How does the aging mechanism work?**
The effective priority of a task increases based on the `agingRate` multiplied by the time the task has spent waiting in the queue, up to the defined `maxPriority`.

**How is starvation detected?**
Starvation is flagged if a task's wait time exceeds ten times the average wait time, or if a task waits longer than 60 seconds when the aging rate is zero.

**Can I simulate different agent counts?**
Yes, the `simulate_scheduling` tool allows you to specify the `agentCount` to see how different numbers of workers affect throughput and wait times.
