【发布时间】:2011-12-21 11:49:37
【问题描述】:
我正在做一个课堂项目,可能是最糟糕的指令,我们必须实现一个简单的调度程序。虽然 C 编程不是课程的先决条件,但这是调度程序的语言,我不是一定是 C 程序员..
无论如何,我正在尝试通过打印任务来调试它,以便我可以通过程序对其进行跟踪,但我不断收到以下编译时错误:
schedule.c:61:48: 错误:取消引用指向不完整类型的指针
这是task_struct 定义:
struct task_struct
{
struct thread_info *thread_info;
int prio, static_prio, normal_prio;
unsigned long sleep_avg;
unsigned long long last_ran;
unsigned long long timestamp;
unsigned long long sched_time;
unsigned int time_slice, first_time_slice;
struct list_head run_list;
struct sched_array *array;
enum sleep_type sleep_type;
int need_reschedule;
};
我试图在里面调试的函数:
void initschedule(struct runqueue *newrq, struct task_struct *seedTask)
{
printf("Inside initschedule()\n");
printf("%s - TEST \n", (seedTask)->thread_info->processName); //causes compiler error
/* initialize runqueue and current task */
rq = newrq;
current = NULL;
/* allocate memory for runqueue schedule arrays */
rq->active = (struct sched_array*)malloc(sizeof(struct sched_array));
rq->expired = (struct sched_array*)malloc(sizeof(struct sched_array));
/* initialize schedule arrays */
INIT_LIST_HEAD(&rq->active->list);
INIT_LIST_HEAD(&rq->active->list);
/* activate task in scheduler */
activate_task(seedTask);
}
最奇怪的是,当我在调用上述函数的方法中使用相同的printf(...) 时,它可以工作,但在我传入seedTask 的函数中却不行。
所以基本上,我想知道为什么会出现这个错误?
【问题讨论】:
标签: c linux scheduling