00001
00022
00023
00024
00025
00026 #ifndef _QUEUE_H_
00027 #define _QUEUE_H_
00028
00029 #ifndef NSEM
00030 #define NSEM 100
00031 #endif
00032
00033 #ifndef NQENT
00034 #define NQENT NPROC \
00035 + 2 \
00036 + 2 \
00037 + NSEM + NSEM
00038 #endif
00039
00040 typedef unsigned long queue;
00041
00042 struct qentry
00043 {
00044 short key;
00045 short next;
00046 short prev;
00047 };
00048
00049 extern struct qentry queuetab[];
00050 extern queue readylist;
00051
00052
00053
00054 #define queuehead(q) (((q) >> 16) & 0xFFFF)
00055 #define queuetail(q) ((q) & 0xFFFF)
00056
00061 #define isbadqueue(x) (queuehead(x)<0 || (queuehead(x) != (queuetail(x) - 1)) || queuetail(x)>=NQENT)
00062
00063 #define isempty(q) (queuetab[queuehead(q)].next >= NPROC)
00064 #define nonempty(q) (queuetab[queuehead(q)].next < NPROC)
00065 #define firstkey(q) (queuetab[queuetab[queuehead(q)].next].key)
00066 #define lastkey(q) (queuetab[queuetab[queuetail(q)].prev].key)
00067 #define firstid(q) (queuetab[queuehead(q)].next)
00068
00069 short enqueue(short, queue);
00070 short insert(short, queue, short);
00071 short insertd(short, queue, short);
00072 short remove(short);
00073 short dequeue(queue);
00074 queue newqueue(void);
00075
00076 #endif