QUEUE(3) Xinu Programmer's Manual QUEUE(3) NAME queue - q-structure predicates and list manipulation pro- cedures SYNOPSIS #include <q.h> int enqueue(proc, tail) int dequeue(proc) int firstid(head) int firstkey(head) int getfirst(head) int getlast(tail) int insert(proc, head, key) int insertd(proc, head, key) Bool isempty(head) int lastkey(tail) Bool nonempty(head) int head, tail; int proc; int key; DESCRIPTION The _q structure holds doubly-linked lists of processes, including lists of processes that are ready, sleeping, and waiting on a semaphore. These routines manipulate lists in the _q structure as follows. enqueue Add a process to a FIFO list given the process id in argument _p_r_o_c and the _q index of the tail of the list in argument _t_a_i_l. _E_n_q_u_e_u_e returns argument _p_r_o_c to its caller. dequeue Remove a process from a list given the process id. The list on which the process is found need not be speci- fied because it can be determined from the _q structure. _D_e_q_u_e_u_e will remove a process from both FIFO and ordered lists. It returns its argument to the caller. firstid Return the process id of the first process on a list given the _q index of the list head in argument _h_e_a_d. firstkey Return the integer key associated with the first entry on a list given the _q index of the list in argument _h_e_a_d. getfirst Version 6b Printed 1/12/87 1 QUEUE(3) Xinu Programmer's Manual QUEUE(3) Remove the first process from a list and return its process id given the _q index of the head of the list in argument _h_e_a_d. _G_e_t_f_i_r_s_t returns EMPTY if the list is empty, and a process id otherwise. getlast Remove the last process on a list and return its pro- cess id given the _q index of the tail of the list in argument _t_a_i_l. _G_e_t_l_a_s_t returns EMPTY if the list is empty, and a process id otherwise. insert Insert a process into an ordered list given the process id in argument _p_r_o_c, the _q index of the head of the list in argument _h_e_a_d, and an integer key for the pro- cess in argument _k_e_y. Ordered lists are always ordered by increasing key values. _I_n_s_e_r_t returns OK. insertd Insert a process in a delta list given the process id in argument _p_r_o_c, the _q index of the head of the list in argument _h_e_a_d, and an integer key in argument _k_e_y. _I_n_s_e_r_t_d returns OK. isempty Return TRUE if there are no processes on a list, FALSE otherwise, given the _q index of the head of the list in argument _h_e_a_d. lastkey Return the key of the last process in a list given the _q index of the tail of the list in argument _t_a_i_l. nonempty Return TRUE if there is at least one process on a list, FALSE otherwise, given the _q index of the head of the list in argument _h_e_a_d. BUGS Most of these routines do not check for valid arguments or valid lists. Also, they assume interrupts are disabled when called, and will corrupt the list structure if the caller fails to disable interrupts. Version 6b Printed 1/12/87 2