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. */
};
...
You need to have the definition of the structure whos array you create before creating the array(the compiler needs to see the definition of type whos array you create), othewise the type is an Incomplete type for the compiler and it does not know the memory layout of that type and hence cannot create an array of it.
You should put the definition of the structure in a header file and include it whichever files you want to refer to structure elements or do some action which needs the compiler to know of the structure layout.