thr_sleepq.c (235068) | thr_sleepq.c (235218) |
---|---|
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 235068 2012-05-05 23:51:24Z davidxu $ | 26 * $FreeBSD: head/lib/libthr/thread/thr_sleepq.c 235218 2012-05-10 09:30:37Z 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) \ --- 54 unchanged lines hidden (view full) --- 89{ 90 struct sleepqueue_chain *sc; 91 struct pthread *curthread = _get_curthread(); 92 93 sc = SC_LOOKUP(wchan); 94 THR_LOCK_RELEASE(curthread, &sc->sc_lock); 95} 96 | 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) \ --- 54 unchanged lines hidden (view full) --- 89{ 90 struct sleepqueue_chain *sc; 91 struct pthread *curthread = _get_curthread(); 92 93 sc = SC_LOOKUP(wchan); 94 THR_LOCK_RELEASE(curthread, &sc->sc_lock); 95} 96 |
97struct sleepqueue * 98_sleepq_lookup(void *wchan) | 97static inline struct sleepqueue * 98lookup(struct sleepqueue_chain *sc, void *wchan) |
99{ | 99{ |
100 struct sleepqueue_chain *sc; | |
101 struct sleepqueue *sq; 102 | 100 struct sleepqueue *sq; 101 |
103 sc = SC_LOOKUP(wchan); | |
104 LIST_FOREACH(sq, &sc->sc_queues, sq_hash) 105 if (sq->sq_wchan == wchan) 106 return (sq); 107 return (NULL); 108} 109 | 102 LIST_FOREACH(sq, &sc->sc_queues, sq_hash) 103 if (sq->sq_wchan == wchan) 104 return (sq); 105 return (NULL); 106} 107 |
108struct sleepqueue * 109_sleepq_lookup(void *wchan) 110{ 111 return (lookup(SC_LOOKUP(wchan), wchan)); 112} 113 |
|
110void 111_sleepq_add(void *wchan, struct pthread *td) 112{ 113 struct sleepqueue_chain *sc; 114 struct sleepqueue *sq; 115 116 sc = SC_LOOKUP(wchan); | 114void 115_sleepq_add(void *wchan, struct pthread *td) 116{ 117 struct sleepqueue_chain *sc; 118 struct sleepqueue *sq; 119 120 sc = SC_LOOKUP(wchan); |
117 sq = _sleepq_lookup(wchan); | 121 sq = lookup(sc, wchan); |
118 if (sq != NULL) { 119 SLIST_INSERT_HEAD(&sq->sq_freeq, td->sleepqueue, sq_flink); 120 } else { 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 } --- 54 unchanged lines hidden --- | 122 if (sq != NULL) { 123 SLIST_INSERT_HEAD(&sq->sq_freeq, td->sleepqueue, sq_flink); 124 } else { 125 sq = td->sleepqueue; 126 LIST_INSERT_HEAD(&sc->sc_queues, sq, sq_hash); 127 sq->sq_wchan = wchan; 128 /* sq->sq_type = type; */ 129 } --- 54 unchanged lines hidden --- |