/* IPC thread queues. Copyright 1999, 2000, 2001 Johan Rydberg, jrydberg@opencores.org. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "ipc-tqueue.h" /* Initialize thread queue ITQ. */ void ipc_tqueue_init (struct ipc_tqueue *itq) { queue_init (&itq->queue); } /* Enqueue thread TH on thread queue ITQ. TH should be unlocked. */ void ipc_tqueue_enqueue (struct ipc_tqueue *itq, struct thread *th) { thread_lock (th); queue_enter (&itq->queue, th, struct thread *, ipcq); thread_unlock (th); } /* Dequeue thread from thread queue ITQ. Returning it. */ struct thread * ipc_tqueue_dequeue (struct ipc_tqueue *itq) { struct thread *th; if (ipc_tqueue_empty (itq)) return (struct thread *) 0; queue_remove_first (&itq->queue, th, struct thread *, ipcq); return th; }