Deleted Added
full compact
thr_sleepq.c (216642) thr_sleepq.c (234947)
1/*
2 * Copyright (c) 2010 David Xu <davidxu@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
1/*
2 * Copyright (c) 2010 David Xu <davidxu@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * $FreeBSD: head/lib/libthr/thread/thr_sleepq.c 216642 2010-12-22 05:03:24Z davidxu $
26 * $FreeBSD: head/lib/libthr/thread/thr_sleepq.c 234947 2012-05-03 09:17:31Z davidxu $
27 */
28
29#include <stdlib.h>
30#include "thr_private.h"
31
32#define HASHSHIFT 9
33#define HASHSIZE (1 << HASHSHIFT)
34#define SC_HASH(wchan) ((unsigned) \
35 ((((uintptr_t)(wchan) >> 3) \
36 ^ ((uintptr_t)(wchan) >> (HASHSHIFT + 3))) \
37 & (HASHSIZE - 1)))
38#define SC_LOOKUP(wc) &sc_table[SC_HASH(wc)]
39
40struct sleepqueue_chain {
41 struct umutex sc_lock;
27 */
28
29#include <stdlib.h>
30#include "thr_private.h"
31
32#define HASHSHIFT 9
33#define HASHSIZE (1 << HASHSHIFT)
34#define SC_HASH(wchan) ((unsigned) \
35 ((((uintptr_t)(wchan) >> 3) \
36 ^ ((uintptr_t)(wchan) >> (HASHSHIFT + 3))) \
37 & (HASHSIZE - 1)))
38#define SC_LOOKUP(wc) &sc_table[SC_HASH(wc)]
39
40struct sleepqueue_chain {
41 struct umutex sc_lock;
42 int sc_enqcnt;
42 LIST_HEAD(, sleepqueue) sc_queues;
43 int sc_type;
44};
45
46static struct sleepqueue_chain sc_table[HASHSIZE];
47
48void
49_sleepq_init(void)

--- 69 unchanged lines hidden (view full) ---

119 sc = SC_LOOKUP(wchan);
120 sq = td->sleepqueue;
121 LIST_INSERT_HEAD(&sc->sc_queues, sq, sq_hash);
122 sq->sq_wchan = wchan;
123 /* sq->sq_type = type; */
124 }
125 td->sleepqueue = NULL;
126 td->wchan = wchan;
43 LIST_HEAD(, sleepqueue) sc_queues;
44 int sc_type;
45};
46
47static struct sleepqueue_chain sc_table[HASHSIZE];
48
49void
50_sleepq_init(void)

--- 69 unchanged lines hidden (view full) ---

120 sc = SC_LOOKUP(wchan);
121 sq = td->sleepqueue;
122 LIST_INSERT_HEAD(&sc->sc_queues, sq, sq_hash);
123 sq->sq_wchan = wchan;
124 /* sq->sq_type = type; */
125 }
126 td->sleepqueue = NULL;
127 td->wchan = wchan;
127 TAILQ_INSERT_TAIL(&sq->sq_blocked, td, wle);
128 if (((++sc->sc_enqcnt << _thr_queuefifo) & 0xff) != 0)
129 TAILQ_INSERT_HEAD(&sq->sq_blocked, td, wle);
130 else
131 TAILQ_INSERT_TAIL(&sq->sq_blocked, td, wle);
128}
129
130int
131_sleepq_remove(struct sleepqueue *sq, struct pthread *td)
132{
133 int rc;
134
135 TAILQ_REMOVE(&sq->sq_blocked, td, wle);

--- 40 unchanged lines hidden ---
132}
133
134int
135_sleepq_remove(struct sleepqueue *sq, struct pthread *td)
136{
137 int rc;
138
139 TAILQ_REMOVE(&sq->sq_blocked, td, wle);

--- 40 unchanged lines hidden ---