From owner-svn-src-user@FreeBSD.ORG Sat Feb 23 08:19:25 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id C69C549D; Sat, 23 Feb 2013 08:19:25 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 973E7152; Sat, 23 Feb 2013 08:19:25 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r1N8JP01017728; Sat, 23 Feb 2013 08:19:25 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r1N8JPbT017726; Sat, 23 Feb 2013 08:19:25 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <201302230819.r1N8JPbT017726@svn.freebsd.org> From: Dmitry Chagin Date: Sat, 23 Feb 2013 08:19:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r247173 - in user/dchagin/lemul/sys: kern sys X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Feb 2013 08:19:25 -0000 Author: dchagin Date: Sat Feb 23 08:19:24 2013 New Revision: 247173 URL: http://svnweb.freebsd.org/changeset/base/247173 Log: 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(). Modified: user/dchagin/lemul/sys/kern/kern_thr.c user/dchagin/lemul/sys/sys/syscallsubr.h Modified: user/dchagin/lemul/sys/kern/kern_thr.c ============================================================================== --- user/dchagin/lemul/sys/kern/kern_thr.c Sat Feb 23 08:17:44 2013 (r247172) +++ user/dchagin/lemul/sys/kern/kern_thr.c Sat Feb 23 08:19:24 2013 (r247173) @@ -162,12 +162,6 @@ create_thread(struct thread *td, mcontex 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: @@ -195,11 +189,9 @@ create_thread(struct thread *td, mcontex #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); @@ -560,3 +552,20 @@ sys_thr_set_name(struct thread *td, stru 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); +} Modified: user/dchagin/lemul/sys/sys/syscallsubr.h ============================================================================== --- user/dchagin/lemul/sys/sys/syscallsubr.h Sat Feb 23 08:17:44 2013 (r247172) +++ user/dchagin/lemul/sys/sys/syscallsubr.h Sat Feb 23 08:19:24 2013 (r247173) @@ -223,6 +223,7 @@ int kern_symlink(struct thread *td, char enum uio_seg segflg); int kern_symlinkat(struct thread *td, char *path1, int fd, char *path2, enum uio_seg segflg); +int kern_thr_alloc(struct proc *, int pages, struct thread **); int kern_thr_exit(struct thread *td); int kern_thr_new(struct thread *td, struct thr_param *param); int kern_thr_suspend(struct thread *td, struct timespec *tsp);