C# 使用异步等待的多队列调度器

C# 使用异步等待的多队列调度器,c#,async-await,C#,Async Await,我正在尝试实现一个多队列调度器,它使用循环和FCFS队列以及单个I/O队列。我曾考虑过使用C#,因为有任务(异步,等待…)的功能,但是我在实现消耗进程的方法时遇到了问题。我创建了一个结构,其中循环和FCF位于链接列表中。第一个队列具有更高的优先级(第二个更小,第三个更小…),当进程离开I/O队列时,它需要在第一个队列中使用,这会导致其他队列中的抢占。直到现在,我的代码看起来像这样。有人能帮助我实现如何使用I/O队列以及如何检测抢占吗。多谢各位 public void Consume(){

我正在尝试实现一个多队列调度器,它使用循环和FCFS队列以及单个I/O队列。我曾考虑过使用C#,因为有任务(异步,等待…)的功能,但是我在实现消耗进程的方法时遇到了问题。我创建了一个结构,其中循环和FCF位于链接列表中。第一个队列具有更高的优先级(第二个更小,第三个更小…),当进程离开I/O队列时,它需要在第一个队列中使用,这会导致其他队列中的抢占。直到现在,我的代码看起来像这样。有人能帮助我实现如何使用I/O队列以及如何检测抢占吗。多谢各位

public void Consume(){
            IQueue curr = FirstLine;
            while(true){
                if(NumberOfProcess == 0){
                    PrintGantt();
                    return;
                }
                if(DetectStandBy()){
                    //TODO
                    //All process in I/O line
                }
                if(curr.LineIsEmpty){
                    curr = (curr.NextLine != null) ? curr.NextLine : FirstLine; 
                    continue;
                }
                Process process = curr.Line.Dequeue();
                if(DetectPreemption(process)){
                    //TODO
                }
                if(process.Processed + curr.Quantum < process.BurstTime){
                    AppendEvent(process.Name, Clock.Time, Clock.IncrementTime(curr.Quantum));
                    process.Processed += curr.Quantum;
                    curr.NextLine.Line.Enqueue(process);
                }
                else{
                    AppendEvent(process.Name, Clock.Time, Clock.IncrementTime(process.BurstTime - process.Processed));
                    process.Reset();
                    process.NumberOfBurst--;
                    if(process.NumberOfIOs > 0){
                        process.NumberOfIOs--;
                        IoLine.Line.Enqueue(process);
                        //TODO -> Consume paralel
                        //ConsumeIo();
                    }
                }
            }
        }
public-void-consumer(){
IQueue curr=第一行;
while(true){
if(NumberOfProcess==0){
PrintGantt();
返回;
}
if(DetectStandBy()){
//待办事项
//I/O线中的所有进程
}
如果(当前行为空){
curr=(curr.NextLine!=null)?curr.NextLine:第一行;
继续;
}
Process Process=curr.Line.Dequeue();
if(检测请求(过程)){
//待办事项
}
if(process.Processed+curr.Quantum0){
process.NumberOfIOs--;
IoLine.Line.Enqueue(进程);
//待办事项->并行消费
//消费者();
}
}
}
}

<>代码>也许您可以考虑使用消息队列API。