Deleted Added
full compact
thr_init.c (118747) thr_init.c (119063)
1/*
2 * Copyright (c) 2003 Daniel M. Eischen <deischen@freebsd.org>
3 * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
1/*
2 * Copyright (c) 2003 Daniel M. Eischen <deischen@freebsd.org>
3 * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * $FreeBSD: head/lib/libkse/thread/thr_init.c 118747 2003-08-10 22:30:20Z davidxu $
33 * $FreeBSD: head/lib/libkse/thread/thr_init.c 119063 2003-08-18 03:58:29Z davidxu $
34 */
35
36/* Allocate space for global thread variables here: */
37#define GLOBAL_PTHREAD_PRIVATE
38
39#include "namespace.h"
40#include <sys/param.h>
41#include <sys/types.h>

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

263#else
264 _kse_initial = _kse_alloc(NULL, 0);
265#endif
266 if (_kse_initial == NULL)
267 PANIC("Can't allocate initial kse.");
268 _kse_initial->k_kseg = _kseg_alloc(NULL);
269 if (_kse_initial->k_kseg == NULL)
270 PANIC("Can't allocate initial kseg.");
34 */
35
36/* Allocate space for global thread variables here: */
37#define GLOBAL_PTHREAD_PRIVATE
38
39#include "namespace.h"
40#include <sys/param.h>
41#include <sys/types.h>

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

263#else
264 _kse_initial = _kse_alloc(NULL, 0);
265#endif
266 if (_kse_initial == NULL)
267 PANIC("Can't allocate initial kse.");
268 _kse_initial->k_kseg = _kseg_alloc(NULL);
269 if (_kse_initial->k_kseg == NULL)
270 PANIC("Can't allocate initial kseg.");
271#ifdef SYSTEM_SCOPE_ONLY
272 _kse_initial->k_kseg->kg_flags |= KGF_SINGLE_THREAD;
271 _kse_initial->k_kseg->kg_flags |= KGF_SINGLE_THREAD;
273#endif
274 _kse_initial->k_schedq = &_kse_initial->k_kseg->kg_schedq;
275
276 TAILQ_INSERT_TAIL(&_kse_initial->k_kseg->kg_kseq, _kse_initial, k_kgqe);
277 _kse_initial->k_kseg->kg_ksecount = 1;
278
279 /* Set the initial thread. */
280 if (curthread == NULL) {
281 /* Create and initialize the initial thread. */

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

304 THR_LIST_ADD(_thr_initial);
305 KSEG_THRQ_ADD(_kse_initial->k_kseg, _thr_initial);
306
307 /* Setup the KSE/thread specific data for the current KSE/thread. */
308 _thr_initial->kse->k_curthread = _thr_initial;
309 _kcb_set(_thr_initial->kse->k_kcb);
310 _tcb_set(_thr_initial->kse->k_kcb, _thr_initial->tcb);
311 _thr_initial->kse->k_flags |= KF_INITIALIZED;
272 _kse_initial->k_schedq = &_kse_initial->k_kseg->kg_schedq;
273
274 TAILQ_INSERT_TAIL(&_kse_initial->k_kseg->kg_kseq, _kse_initial, k_kgqe);
275 _kse_initial->k_kseg->kg_ksecount = 1;
276
277 /* Set the initial thread. */
278 if (curthread == NULL) {
279 /* Create and initialize the initial thread. */

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

302 THR_LIST_ADD(_thr_initial);
303 KSEG_THRQ_ADD(_kse_initial->k_kseg, _thr_initial);
304
305 /* Setup the KSE/thread specific data for the current KSE/thread. */
306 _thr_initial->kse->k_curthread = _thr_initial;
307 _kcb_set(_thr_initial->kse->k_kcb);
308 _tcb_set(_thr_initial->kse->k_kcb, _thr_initial->tcb);
309 _thr_initial->kse->k_flags |= KF_INITIALIZED;
310
311 _thr_signal_init();
312 _kse_critical_leave(&_thr_initial->tcb->tcb_tmbx);
312}
313
314/*
315 * This function and pthread_create() do a lot of the same things.
316 * It'd be nice to consolidate the common stuff in one place.
317 */
318static void
319init_main_thread(struct pthread *thread)
320{
321 int i;
322
323 /* Setup the thread attributes. */
324 thread->attr = _pthread_attr_default;
313}
314
315/*
316 * This function and pthread_create() do a lot of the same things.
317 * It'd be nice to consolidate the common stuff in one place.
318 */
319static void
320init_main_thread(struct pthread *thread)
321{
322 int i;
323
324 /* Setup the thread attributes. */
325 thread->attr = _pthread_attr_default;
325#ifdef SYSTEM_SCOPE_ONLY
326 thread->attr.flags |= PTHREAD_SCOPE_SYSTEM;
326 thread->attr.flags |= PTHREAD_SCOPE_SYSTEM;
327#endif
328 /*
329 * Set up the thread stack.
330 *
331 * Create a red zone below the main stack. All other stacks
332 * are constrained to a maximum size by the parameters
333 * passed to mmap(), but this stack is only limited by
334 * resource limits, so this stack needs an explicitly mapped
335 * red zone to protect the thread stack that is just beyond.

--- 157 unchanged lines hidden ---
327 /*
328 * Set up the thread stack.
329 *
330 * Create a red zone below the main stack. All other stacks
331 * are constrained to a maximum size by the parameters
332 * passed to mmap(), but this stack is only limited by
333 * resource limits, so this stack needs an explicitly mapped
334 * red zone to protect the thread stack that is just beyond.

--- 157 unchanged lines hidden ---