summaryrefslogtreecommitdiffstats
path: root/bin/ps
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2007-10-26 08:00:41 +0000
committerjulian <julian@FreeBSD.org>2007-10-26 08:00:41 +0000
commit11e1aa0d189878b719971121400f0678e7ccb2aa (patch)
treee047e33390a9aae820357c54ff8602bc8faad475 /bin/ps
parent050649d6404e24b1beaba91f04f9008ad5acd6a5 (diff)
downloadFreeBSD-src-11e1aa0d189878b719971121400f0678e7ccb2aa.zip
FreeBSD-src-11e1aa0d189878b719971121400f0678e7ccb2aa.tar.gz
Introduce a way to make pure kernal threads.
kthread_add() takes the same parameters as the old kthread_create() plus a pointer to a process structure, and adds a kernel thread to that process. kproc_kthread_add() takes the parameters for kthread_add, plus a process name and a pointer to a pointer to a process instead of just a pointer, and if the proc * is NULL, it creates the process to the specifications required, before adding the thread to it. All other old kthread_xxx() calls return, but act on (struct thread *) instead of (struct proc *). One reason to change the name is so that any old kernel modules that are lying around and expect kthread_create() to make a process will not just accidentally link. fix top to show kernel threads by their thread name in -SH mode add a tdnam formatting option to ps to show thread names. make all idle threads actual kthreads and put them into their own idled process. make all interrupt threads kthreads and put them in an interd process (mainly for aesthetic and accounting reasons) rename proc 0 to be 'kernel' and it's swapper thread is now 'swapper' man page fixes to follow.
Diffstat (limited to 'bin/ps')
-rw-r--r--bin/ps/extern.h3
-rw-r--r--bin/ps/keyword.c2
-rw-r--r--bin/ps/print.c25
-rw-r--r--bin/ps/ps.c3
4 files changed, 27 insertions, 6 deletions
diff --git a/bin/ps/extern.h b/bin/ps/extern.h
index 08b6d9b..89b5835 100644
--- a/bin/ps/extern.h
+++ b/bin/ps/extern.h
@@ -39,7 +39,7 @@ extern fixpt_t ccpu;
extern int cflag, eval, fscale, nlistread, rawcpu;
extern unsigned long mempages;
extern time_t now;
-extern int sumrusage, termwidth, totwidth;
+extern int showthreads, sumrusage, termwidth, totwidth;
extern STAILQ_HEAD(velisthead, varent) varlist;
__BEGIN_DECLS
@@ -78,6 +78,7 @@ int s_uname(KINFO *);
void showkey(void);
void started(KINFO *, VARENT *);
void state(KINFO *, VARENT *);
+void tdnam(KINFO *, VARENT *);
void tdev(KINFO *, VARENT *);
void tname(KINFO *, VARENT *);
void ucomm(KINFO *, VARENT *);
diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c
index b7a887bc..9eea8d3 100644
--- a/bin/ps/keyword.c
+++ b/bin/ps/keyword.c
@@ -187,6 +187,8 @@ static VAR var[] = {
UINT, UIDFMT, 0},
{"tdev", "TDEV", NULL, 0, tdev, NULL, 4, 0, CHAR, NULL, 0},
{"time", "TIME", NULL, USER, cputime, NULL, 9, 0, CHAR, NULL, 0},
+ {"tdnam", "THRDNAME", NULL, LJUST, tdnam, NULL, COMMLEN, 0, CHAR,
+ NULL, 0},
{"tpgid", "TPGID", NULL, 0, kvar, NULL, 4, KOFF(ki_tpgid), UINT,
PIDFMT, 0},
{"tsid", "TSID", NULL, 0, kvar, NULL, PIDLEN, KOFF(ki_tsid), UINT,
diff --git a/bin/ps/print.c b/bin/ps/print.c
index 29dffb6..544ca0e 100644
--- a/bin/ps/print.c
+++ b/bin/ps/print.c
@@ -129,9 +129,11 @@ command(KINFO *k, VARENT *ve)
v = ve->var;
if (cflag) {
/* If it is the last field, then don't pad */
- if (STAILQ_NEXT(ve, next_ve) == NULL)
+ if (STAILQ_NEXT(ve, next_ve) == NULL) {
(void)printf("%s", k->ki_p->ki_comm);
- else
+ if (showthreads && k->ki_p->ki_numthreads > 1)
+ printf("/%s", k->ki_p->ki_ocomm);
+ } else
(void)printf("%-*s", v->width, k->ki_p->ki_comm);
return;
}
@@ -178,13 +180,28 @@ ucomm(KINFO *k, VARENT *ve)
VAR *v;
v = ve->var;
- if (STAILQ_NEXT(ve, next_ve) == NULL) /* last field, don't pad */
+ if (STAILQ_NEXT(ve, next_ve) == NULL) { /* last field, don't pad */
(void)printf("%s", k->ki_p->ki_comm);
- else
+ if (showthreads && k->ki_p->ki_numthreads > 1)
+ printf("/%s", k->ki_p->ki_ocomm);
+ } else
(void)printf("%-*s", v->width, k->ki_p->ki_comm);
}
void
+tdnam(KINFO *k, VARENT *ve)
+{
+ VAR *v;
+
+ v = ve->var;
+ if (showthreads && k->ki_p->ki_numthreads > 1)
+ (void)printf("%-*s", v->width, k->ki_p->ki_ocomm);
+ else
+ (void)printf("%-*s", v->width, " " );
+
+}
+
+void
logname(KINFO *k, VARENT *ve)
{
VAR *v;
diff --git a/bin/ps/ps.c b/bin/ps/ps.c
index ee2b7f8..7ced4f4 100644
--- a/bin/ps/ps.c
+++ b/bin/ps/ps.c
@@ -98,6 +98,7 @@ int rawcpu; /* -C */
int sumrusage; /* -S */
int termwidth; /* Width of the screen (0 == infinity). */
int totwidth; /* Calculated-width of requested variables. */
+int showthreads; /* will threads be shown? */
struct velisthead varlist = STAILQ_HEAD_INITIALIZER(varlist);
@@ -175,7 +176,7 @@ main(int argc, char *argv[])
char *cols;
int all, ch, elem, flag, _fmt, i, lineno;
int nentries, nkept, nselectors;
- int prtheader, showthreads, wflag, what, xkeep, xkeep_implied;
+ int prtheader, wflag, what, xkeep, xkeep_implied;
char errbuf[_POSIX2_LINE_MAX];
(void) setlocale(LC_ALL, "");
OpenPOWER on IntegriCloud