MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vm_thread_new

Function vm_thread_new

freebsd/vm/vm_glue.c:361–389  ·  view source on GitHub ↗

* Allocate the kernel stack for a new thread. */

Source from the content-addressed store, hash-verified

359 * Allocate the kernel stack for a new thread.
360 */
361int
362vm_thread_new(struct thread *td, int pages)
363{
364 vm_offset_t ks;
365
366 /* Bounds check */
367 if (pages <= 1)
368 pages = kstack_pages;
369 else if (pages > KSTACK_MAX_PAGES)
370 pages = KSTACK_MAX_PAGES;
371
372 ks = 0;
373 if (pages == kstack_pages && kstack_cache != NULL)
374 ks = (vm_offset_t)uma_zalloc(kstack_cache, M_NOWAIT);
375
376 /*
377 * Ensure that kstack objects can draw pages from any memory
378 * domain. Otherwise a local memory shortage can block a process
379 * swap-in.
380 */
381 if (ks == 0)
382 ks = vm_thread_stack_create(DOMAINSET_PREF(PCPU_GET(domain)),
383 pages);
384 if (ks == 0)
385 return (0);
386 td->td_kstack = ks;
387 td->td_kstack_pages = pages;
388 return (1);
389}
390
391/*
392 * Dispose of a thread's kernel stack.

Callers 2

thread_allocFunction · 0.85
thread_alloc_stackFunction · 0.85

Calls 2

vm_thread_stack_createFunction · 0.85
uma_zallocFunction · 0.70

Tested by

no test coverage detected