if ((*p)->state == TASK_RUNNING && (*p)->counter > c) c = (*p)->counter, next = i;