summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2006-02-05 02:18:46 +0000
committerdavidxu <davidxu@FreeBSD.org>2006-02-05 02:18:46 +0000
commit7ef206e1a842032c820ef523ad14364862168a05 (patch)
treec64365126251949792afeea41bfd988ab18d50c0
parentf2384c93e3e037aeae70e774832e2695f10c6b10 (diff)
downloadFreeBSD-src-7ef206e1a842032c820ef523ad14364862168a05.zip
FreeBSD-src-7ef206e1a842032c820ef523ad14364862168a05.tar.gz
Implement thr_set_name to set a name for thread.
Reviewed by: julian
-rw-r--r--sys/kern/kern_thr.c29
-rw-r--r--sys/kern/syscalls.master1
-rw-r--r--sys/sys/thr.h2
3 files changed, 31 insertions, 1 deletions
diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c
index 2a20bb1..86df4d7 100644
--- a/sys/kern/kern_thr.c
+++ b/sys/kern/kern_thr.c
@@ -407,3 +407,32 @@ thr_wake(struct thread *td, struct thr_wake_args *uap)
PROC_UNLOCK(p);
return (0);
}
+
+int
+thr_set_name(struct thread *td, struct thr_set_name_args *uap)
+{
+ struct proc *p = td->td_proc;
+ char name[MAXCOMLEN + 1];
+ struct thread *ttd;
+ int error;
+
+ error = 0;
+ name[0] = '\0';
+ if (uap->name != NULL) {
+ error = copyinstr(uap->name, name, sizeof(name),
+ NULL);
+ if (error)
+ return (error);
+ }
+ PROC_LOCK(p);
+ if (uap->id == td->td_tid)
+ ttd = td;
+ else
+ ttd = thread_find(p, uap->id);
+ if (ttd != NULL)
+ strcpy(ttd->td_name, name);
+ else
+ error = ESRCH;
+ PROC_UNLOCK(p);
+ return (error);
+}
diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master
index aa84a00..c8715d9 100644
--- a/sys/kern/syscalls.master
+++ b/sys/kern/syscalls.master
@@ -816,5 +816,6 @@
const struct sigevent *sigev); }
462 AUE_NULL MNOSTD { int mq_unlink(const char *path); }
463 AUE_NULL MSTD { int abort2(const char *why, int nargs, void **args); }
+464 AUE_NULL MSTD { int thr_set_name(long id, const char *name); }
; Please copy any additions and changes to the following compatability tables:
; sys/compat/freebsd32/syscalls.master
diff --git a/sys/sys/thr.h b/sys/sys/thr.h
index 155e79b..ce6d535 100644
--- a/sys/sys/thr.h
+++ b/sys/sys/thr.h
@@ -60,7 +60,7 @@ void thr_exit(long *state);
int thr_kill(long id, int sig);
int thr_suspend(const struct timespec *timeout);
int thr_wake(long id);
-
+int thr_set_name(long id, const char *name);
#endif /* !_KERNEL */
#endif /* ! _SYS_THR_H_ */
OpenPOWER on IntegriCloud