/* bottom-half.c - Bottom half implementation. Copyright (C) 2009 Free Software Foundation, Inc. Written by Neal H. Walfield . This file is part of the GNU Hurd. The GNU Hurd 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 3 of the License, or (at your option) any later version. The GNU Hurd 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, see . */ #include "bottom-half.h" struct bottom_half *bottom_halves; void bottom_half_register (struct bottom_half *bh) { assert (! bh->next); assert (bh != bottom_halves); do bh->next = bottom_halves; while (__sync_val_compare_and_swap (&bottom_halves, bh->next, bh) != bh->next); } void bottom_half_run_hard (void) { struct bottom_half *bh; do bh = bottom_halves; while (bh && !__sync_val_compare_and_swap (&bottom_halves, bh, 0)); if (! bh) return; struct bottom_half *next = bh; while ((bh = next)) { next = bh->next; bh->next = 0; bh->callback (bh); } }