c - 在 Linux 内核编程中进行 CPU SRJF 调度时发生 En/取消排队错误



我想做SRJF调度源。但它不能正常工作。编译是可以的,但我无法正确获得我期望的结果。如何修复或修改?我认为排队部分和取消排队部分有问题。

struct sched_array {
  struct list_head list;
  struct task_struct task;
};
void enqueue_task(struct task_struct *p, struct sched_array *array)
{
  struct sched_array *new = (struct sched_array *) malloc( sizeof(struct sched_array) );
  p->array = new;
  new->task = p;
  list_add( &new->list, &array->list )
}
void dequeue_task(struct task_struct *p, struct sched_array *array)
{
  if (rq->curr = p)
  {
    rq->curr = NULL;
  }
  list_del(&(p->array->list));
}

我在这里看到的一个问题是,

  new->task = p;

您正在将类型 struct task_struct *p分配给类型 struct task_structtask

请注意p是指针,而task不是。

也许你的意思是,

  new->task = *p;

然而,我们需要最小可重现的例子来完全解决问题。

最新更新