Implement thr_set_name to set a name for thread.

Reviewed by: julian
This commit is contained in:
David Xu 2006-02-05 02:18:46 +00:00
parent 1248f2322b
commit 9e7d72246f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=155327
3 changed files with 31 additions and 1 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -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_ */