From a30bee2fab87f02656882fd01af38fbf4858f88f Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 13 Aug 2025 13:51:35 +0200 Subject: [PATCH] DLSCH sched: Fix coefficients for UE list ordering Update the comparator() to properly sort UEs based on their coefficient by appliey a consistent logic of -1/0/1 (see man qsort) for smaller/equal/larger. The previous logic was only sorting based on 0/1 (equal/larger), which would result in some UEs with a high coefficient not necessarily advancing to the start of the list, which could reduce the likelihood of them being scheduled when they actually should (in other words, this should improve fairness). See also: 62e4025bc846 ("Integrate inactivity scheduling into main allocation loop") --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index f831e8af2e..c88ad3bd96 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -594,8 +594,15 @@ typedef struct UEsched_s { NR_UE_info_t * UE; } UEsched_t; -static int comparator(const void *p, const void *q) { - return ((UEsched_t*)p)->coef < ((UEsched_t*)q)->coef; +static int comparator(const void *p, const void *q) +{ + const UEsched_t *pp = p; + const UEsched_t *qq = q; + if (pp->coef < qq->coef) + return 1; + else if (pp->coef > qq->coef) + return -1; + return 0; } static void pf_dl(module_id_t module_id,