diff options
author | dchagin <dchagin@FreeBSD.org> | 2015-05-24 14:37:45 +0000 |
---|---|---|
committer | dchagin <dchagin@FreeBSD.org> | 2015-05-24 14:37:45 +0000 |
commit | 4d4fc642c1cac69730bd677223d965ae7b270dda (patch) | |
tree | 1e17e76cd5c42a141d883856f35f17d26364af34 /sys/kern/kern_thr.c | |
parent | aa808515271af610d5e6fc4c1a12b83763077564 (diff) | |
download | FreeBSD-src-4d4fc642c1cac69730bd677223d965ae7b270dda.zip FreeBSD-src-4d4fc642c1cac69730bd677223d965ae7b270dda.tar.gz |
In preparation for switching linuxulator to the use the native 1:1
threads introduce kern_thr_alloc() which will be used later in the
linux_clone().
Differential Revision: https://reviews.freebsd.org/D1029
Reviewed by: trasz
Diffstat (limited to 'sys/kern/kern_thr.c')
-rw-r--r-- | sys/kern/kern_thr.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c index e686b22..6cd215e 100644 --- a/sys/kern/kern_thr.c +++ b/sys/kern/kern_thr.c @@ -162,12 +162,6 @@ create_thread(struct thread *td, mcontext_t *ctx, p = td->td_proc; - /* Have race condition but it is cheap. */ - if (p->p_numthreads >= max_threads_per_proc) { - ++max_threads_hits; - return (EPROCLIM); - } - if (rtp != NULL) { switch(rtp->type) { case RTP_PRIO_REALTIME: @@ -197,11 +191,9 @@ create_thread(struct thread *td, mcontext_t *ctx, #endif /* Initialize our td */ - newtd = thread_alloc(0); - if (newtd == NULL) { - error = ENOMEM; + error = kern_thr_alloc(p, 0, &newtd); + if (error) goto fail; - } cpu_set_upcall(newtd, td); @@ -566,3 +558,20 @@ sys_thr_set_name(struct thread *td, struct thr_set_name_args *uap) PROC_UNLOCK(p); return (error); } + +int +kern_thr_alloc(struct proc *p, int pages, struct thread **ntd) +{ + + /* Have race condition but it is cheap. */ + if (p->p_numthreads >= max_threads_per_proc) { + ++max_threads_hits; + return (EPROCLIM); + } + + *ntd = thread_alloc(pages); + if (*ntd == NULL) + return (ENOMEM); + + return (0); +} |