Deleted Added
full compact
thr_init.c (139023) thr_init.c (141822)
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 139023 2004-12-18 18:07:37Z deischen $
33 * $FreeBSD: head/lib/libkse/thread/thr_init.c 141822 2005-02-13 18:38:06Z deischen $
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>

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

332 * Set up the thread stack.
333 *
334 * Create a red zone below the main stack. All other stacks
335 * are constrained to a maximum size by the parameters
336 * passed to mmap(), but this stack is only limited by
337 * resource limits, so this stack needs an explicitly mapped
338 * red zone to protect the thread stack that is just beyond.
339 */
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>

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

332 * Set up the thread stack.
333 *
334 * Create a red zone below the main stack. All other stacks
335 * are constrained to a maximum size by the parameters
336 * passed to mmap(), but this stack is only limited by
337 * resource limits, so this stack needs an explicitly mapped
338 * red zone to protect the thread stack that is just beyond.
339 */
340 if (mmap((void *)_usrstack - THR_STACK_INITIAL -
340 if (mmap((void *)_usrstack - _thr_stack_initial -
341 _thr_guard_default, _thr_guard_default, 0, MAP_ANON,
342 -1, 0) == MAP_FAILED)
343 PANIC("Cannot allocate red zone for initial thread");
344
345 /*
346 * Mark the stack as an application supplied stack so that it
347 * isn't deallocated.
348 *
349 * XXX - I'm not sure it would hurt anything to deallocate
350 * the main thread stack because deallocation doesn't
351 * actually free() it; it just puts it in the free
352 * stack queue for later reuse.
353 */
341 _thr_guard_default, _thr_guard_default, 0, MAP_ANON,
342 -1, 0) == MAP_FAILED)
343 PANIC("Cannot allocate red zone for initial thread");
344
345 /*
346 * Mark the stack as an application supplied stack so that it
347 * isn't deallocated.
348 *
349 * XXX - I'm not sure it would hurt anything to deallocate
350 * the main thread stack because deallocation doesn't
351 * actually free() it; it just puts it in the free
352 * stack queue for later reuse.
353 */
354 thread->attr.stackaddr_attr = (void *)_usrstack - THR_STACK_INITIAL;
355 thread->attr.stacksize_attr = THR_STACK_INITIAL;
354 thread->attr.stackaddr_attr = (void *)_usrstack - _thr_stack_initial;
355 thread->attr.stacksize_attr = _thr_stack_initial;
356 thread->attr.guardsize_attr = _thr_guard_default;
357 thread->attr.flags |= THR_STACK_USER;
358
359 /*
360 * Write a magic value to the thread structure
361 * to help identify valid ones:
362 */
363 thread->magic = THR_MAGIC;

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

422 len = sizeof (struct clockinfo);
423 if (sysctl(mib, 2, &clockinfo, &len, NULL, 0) == 0)
424 _clock_res_usec = clockinfo.tick;
425 else
426 _clock_res_usec = CLOCK_RES_USEC;
427
428 _thr_page_size = getpagesize();
429 _thr_guard_default = _thr_page_size;
356 thread->attr.guardsize_attr = _thr_guard_default;
357 thread->attr.flags |= THR_STACK_USER;
358
359 /*
360 * Write a magic value to the thread structure
361 * to help identify valid ones:
362 */
363 thread->magic = THR_MAGIC;

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

422 len = sizeof (struct clockinfo);
423 if (sysctl(mib, 2, &clockinfo, &len, NULL, 0) == 0)
424 _clock_res_usec = clockinfo.tick;
425 else
426 _clock_res_usec = CLOCK_RES_USEC;
427
428 _thr_page_size = getpagesize();
429 _thr_guard_default = _thr_page_size;
430 if (sizeof(void *) == 8) {
431 _thr_stack_default = THR_STACK64_DEFAULT;
432 _thr_stack_initial = THR_STACK64_INITIAL;
433 }
434 else {
435 _thr_stack_default = THR_STACK32_DEFAULT;
436 _thr_stack_initial = THR_STACK32_INITIAL;
437 }
430 init_once = 1; /* Don't do this again. */
431 } else {
432 /*
433 * Destroy the locks before creating them. We don't
434 * know what state they are in so it is better to just
435 * recreate them.
436 */
437 _lock_destroy(&_thread_signal_lock);

--- 48 unchanged lines hidden ---
438 init_once = 1; /* Don't do this again. */
439 } else {
440 /*
441 * Destroy the locks before creating them. We don't
442 * know what state they are in so it is better to just
443 * recreate them.
444 */
445 _lock_destroy(&_thread_signal_lock);

--- 48 unchanged lines hidden ---