blob: 3bb081ff59a07eeb2757812160b08a902ea15530 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/* bottom-half.c - Bottom half implementation.
Copyright (C) 2009 Free Software Foundation, Inc.
Written by Neal H. Walfield <neal@gnu.org>.
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
<http://www.gnu.org/licenses/>. */
#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);
}
}
|