Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_thread.c
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
#include <sys/pmckern.h> | #include <sys/pmckern.h> | ||||
#endif | #endif | ||||
#include <security/audit/audit.h> | #include <security/audit/audit.h> | ||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
#include <vm/vm_extern.h> | #include <vm/vm_extern.h> | ||||
#include <vm/uma.h> | #include <vm/uma.h> | ||||
#include <vm/vm_domain.h> | |||||
#include <sys/eventhandler.h> | #include <sys/eventhandler.h> | ||||
SDT_PROVIDER_DECLARE(proc); | SDT_PROVIDER_DECLARE(proc); | ||||
SDT_PROBE_DEFINE(proc, , , lwp__exit); | SDT_PROBE_DEFINE(proc, , , lwp__exit); | ||||
/* | /* | ||||
* thread related storage. | * thread related storage. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 276 Lines • ▼ Show 20 Lines | thread_alloc(int pages) | ||||
td = (struct thread *)uma_zalloc(thread_zone, M_WAITOK); | td = (struct thread *)uma_zalloc(thread_zone, M_WAITOK); | ||||
KASSERT(td->td_kstack == 0, ("thread_alloc got thread with kstack")); | KASSERT(td->td_kstack == 0, ("thread_alloc got thread with kstack")); | ||||
if (!vm_thread_new(td, pages)) { | if (!vm_thread_new(td, pages)) { | ||||
uma_zfree(thread_zone, td); | uma_zfree(thread_zone, td); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
cpu_thread_alloc(td); | cpu_thread_alloc(td); | ||||
vm_domain_policy_init(&td->td_vm_dom_policy); | |||||
return (td); | return (td); | ||||
} | } | ||||
int | int | ||||
thread_alloc_stack(struct thread *td, int pages) | thread_alloc_stack(struct thread *td, int pages) | ||||
{ | { | ||||
KASSERT(td->td_kstack == 0, | KASSERT(td->td_kstack == 0, | ||||
Show All 13 Lines | thread_free(struct thread *td) | ||||
lock_profile_thread_exit(td); | lock_profile_thread_exit(td); | ||||
if (td->td_cpuset) | if (td->td_cpuset) | ||||
cpuset_rel(td->td_cpuset); | cpuset_rel(td->td_cpuset); | ||||
td->td_cpuset = NULL; | td->td_cpuset = NULL; | ||||
cpu_thread_free(td); | cpu_thread_free(td); | ||||
if (td->td_kstack != 0) | if (td->td_kstack != 0) | ||||
vm_thread_dispose(td); | vm_thread_dispose(td); | ||||
vm_domain_policy_cleanup(&td->td_vm_dom_policy); | |||||
uma_zfree(thread_zone, td); | uma_zfree(thread_zone, td); | ||||
} | } | ||||
/* | /* | ||||
* Discard the current thread and exit from its context. | * Discard the current thread and exit from its context. | ||||
* Always called with scheduler locked. | * Always called with scheduler locked. | ||||
* | * | ||||
* Because we can't free a thread while we're operating under its context, | * Because we can't free a thread while we're operating under its context, | ||||
▲ Show 20 Lines • Show All 756 Lines • Show Last 20 Lines |