0

In our class we are to implement a kernel built on a bochs simulator.

One of the subtasks is to implement fixed priority scheduling. Previously our scheduler was only one thread queue, but now i wanted to make an array of thread queues.

But my array keeps getting a comiler error "array type has incomplete element type" i posted some of the code below, can anyone see the problem.

kernel.h

...
extern struct thread_queue
ready_queue_table[MAX_SYS_PRIORITY];
...

kernel.c

...
#include <sysdefines.h>
#include "threadqueue.h"
...
struct thread_queue
ready_queue_table[MAX_SYS_PRIORITY];
...

sysdefines.h

...
#define MAX_SYS_PRIORITY         (5)
...

threadqueue.h

...
struct thread_queue
{
 int head;  /*!< The index to the head of the thread queue.
                 Is -1 if queue is empty. */
 int tail;  /*!< The index to the tail of the thread queue.
                 Is -1 if queue is empty. */
};
...
4

2 回答 2

2

您需要在创建数组之前定义您创建的结构 whos 数组(编译器需要查看您创建的类型 whos 数组的定义),否则该类型对于编译器来说是不完整类型并且它不知道内存该类型的布局,因此无法创建它的数组。

您应该将结构的定义放在头文件中,并将其包含在您想要引用结构元素的任何文件中,或者执行一些需要编译器了解结构布局的操作。

于 2012-04-30T15:49:50.987 回答
0

kernel.h你有这个:

extern struct thread_queue
ready_queue_table[MAX_SYS_PRIORITY];

我怀疑有些事包括kernel.hwherethreadqueue.h还没有包括在内。我认为您需要添加#include "threadqueue.h"kernel.h删除该extern.

但这一切只是猜测,因为代码片段非常稀疏。

于 2012-04-30T16:05:43.450 回答