svn commit: r247173 - in user/dchagin/lemul/sys: kern sys
Dmitry Chagin
dchagin at FreeBSD.org
Sat Feb 23 08:19:25 UTC 2013
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);
More information about the svn-src-user
mailing list