mirror of https://github.com/zrafa/xinu-avr.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
870 B
31 lines
870 B
|
6 years ago
|
/* newqueue.c - newqueue */
|
||
|
|
|
||
|
|
#include <xinu.h>
|
||
|
|
|
||
|
|
/*------------------------------------------------------------------------
|
||
|
|
* newqueue - Allocate and initialize a queue in the global queue table
|
||
|
|
*------------------------------------------------------------------------
|
||
|
|
*/
|
||
|
|
qid16 newqueue(void)
|
||
|
|
{
|
||
|
|
static qid16 nextqid=NPROC; /* Next list in queuetab to use */
|
||
|
|
qid16 q; /* ID of allocated queue */
|
||
|
|
|
||
|
|
q = nextqid;
|
||
|
|
if (q >= NQENT) { /* Check for table overflow */
|
||
|
|
return SYSERR;
|
||
|
|
}
|
||
|
|
|
||
|
|
nextqid += 2; /* Increment index for next call*/
|
||
|
|
|
||
|
|
/* Initialize head and tail nodes to form an empty queue */
|
||
|
|
|
||
|
|
queuetab[queuehead(q)].qnext = queuetail(q);
|
||
|
|
queuetab[queuehead(q)].qprev = EMPTY;
|
||
|
|
queuetab[queuehead(q)].qkey = MAXKEY;
|
||
|
|
queuetab[queuetail(q)].qnext = EMPTY;
|
||
|
|
queuetab[queuetail(q)].qprev = queuehead(q);
|
||
|
|
queuetab[queuetail(q)].qkey = MINKEY;
|
||
|
|
return q;
|
||
|
|
}
|