- /*
- * allocate n x VLIB_THREAD_STACK_SIZE stacks, aligned to a
- * VLIB_THREAD_STACK_SIZE boundary
- * See also: os_get_cpu_number() in vlib/vlib/threads.c
- */
- thread_stacks = clib_mem_alloc_aligned
- ((uword) tm->n_thread_stacks * VLIB_THREAD_STACK_SIZE,
- VLIB_THREAD_STACK_SIZE);
-
- vec_validate (vlib_thread_stacks, tm->n_thread_stacks - 1);
- for (i = 0; i < vec_len (vlib_thread_stacks); i++)
- {
- vlib_thread_stacks[i] = thread_stacks;
-
- /*
- * Disallow writes to the bottom page of the stack, to
- * catch stack overflows.
- */
- if (mprotect (thread_stacks, clib_mem_get_page_size (), PROT_READ) < 0)
- clib_unix_warning ("thread stack");