diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc_r/uthread/uthread_create.c | 4 | ||||
-rw-r--r-- | lib/libc_r/uthread/uthread_info.c | 22 | ||||
-rw-r--r-- | lib/libc_r/uthread/uthread_kern.c | 6 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_create.c | 4 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_info.c | 22 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_kern.c | 6 |
6 files changed, 52 insertions, 12 deletions
diff --git a/lib/libc_r/uthread/uthread_create.c b/lib/libc_r/uthread/uthread_create.c index 1ed287d2b1b..eef5dab9646 100644 --- a/lib/libc_r/uthread/uthread_create.c +++ b/lib/libc_r/uthread/uthread_create.c @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: uthread_create.c,v 1.6 1999/01/17 23:57:27 d Exp $ + * $OpenBSD: uthread_create.c,v 1.7 1999/02/01 08:23:46 d Exp $ */ #include <errno.h> #include <stdlib.h> @@ -89,8 +89,10 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr, new_thread->stack = stack; new_thread->start_routine = start_routine; new_thread->arg = arg; +#ifdef _THREAD_RUSAGE timerclear(&new_thread->ru_utime); timerclear(&new_thread->ru_stime); +#endif _SPINUNLOCK(&new_thread->lock); new_thread->cancelstate = PTHREAD_CANCEL_ENABLE; diff --git a/lib/libc_r/uthread/uthread_info.c b/lib/libc_r/uthread/uthread_info.c index 53b1e220f1d..3e682752474 100644 --- a/lib/libc_r/uthread/uthread_info.c +++ b/lib/libc_r/uthread/uthread_info.c @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: uthread_info.c,v 1.6 1999/01/17 23:58:10 d Exp $ + * $OpenBSD: uthread_info.c,v 1.7 1999/02/01 08:23:46 d Exp $ */ #include <stdio.h> #include <fcntl.h> @@ -108,8 +108,16 @@ _thread_dump_info(void) /* Display a list of active threads */ - snprintf(s, sizeof s, " %8s%c%-11s %2s %5s %-8s %5s %5s %s\n", - "id", ' ', "state", "pr", "flag", "name", "utime", "stime", + snprintf(s, sizeof s, +#ifdef _THREAD_RUSAGE + " %8s%c%-11s %2s %5s %-8s %5s %5s %s\n", +#else + " %8s%c%-11s %2s %5s %-8s %s\n", +#endif + "id", ' ', "state", "pr", "flag", "name", +#ifdef _THREAD_RUSAGE + "utime", "stime", +#endif "location"); _thread_sys_write(fd, s, strlen(s)); @@ -135,7 +143,11 @@ _thread_dump_info(void) /* Output a record for the current thread: */ s[0] = 0; snprintf(s, sizeof(s), - " %8p%c%-11s %2d %c%c%c%c%c %-8s %5.2f %5.2f %s\n", +#ifdef _THREAD_RUSAGE + " %8p%c%-11s %2d %c%c%c%c%c %-8.8s %5.2f %5.2f %s\n", +#else + " %8p%c%-11s %2d %c%c%c%c%c %-8.8s %s\n", +#endif (void *)pthread, (pthread == _thread_run) ? '*' : ' ', state, @@ -148,10 +160,12 @@ _thread_dump_info(void) (pthread->attr.flags & PTHREAD_INHERIT_SCHED) ? 'I' : ' ', (pthread->attr.flags & PTHREAD_NOFLOAT) ? 'F' : ' ', (pthread->name == NULL) ? "" : pthread->name, +#ifdef _THREAD_RUSAGE pthread->ru_utime.tv_sec + (double)pthread->ru_utime.tv_usec / 1000000.0, pthread->ru_stime.tv_sec + (double)pthread->ru_stime.tv_usec / 1000000.0, +#endif location ); _thread_sys_write(fd, s, strlen(s)); diff --git a/lib/libc_r/uthread/uthread_kern.c b/lib/libc_r/uthread/uthread_kern.c index 8d6f58754e6..88fa55e156c 100644 --- a/lib/libc_r/uthread/uthread_kern.c +++ b/lib/libc_r/uthread/uthread_kern.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: uthread_kern.c,v 1.15 1998/11/15 09:58:26 jb Exp $ - * $OpenBSD: uthread_kern.c,v 1.6 1999/01/17 23:49:49 d Exp $ + * $OpenBSD: uthread_kern.c,v 1.7 1999/02/01 08:23:46 d Exp $ * */ #include <errno.h> @@ -67,8 +67,10 @@ _thread_kern_sched(struct sigcontext * scp) struct timespec ts1; struct timeval tv; struct timeval tv1; +#ifdef _THREAD_RUSAGE struct rusage ru; static struct rusage ru_prev; +#endif /* * Flag the pthread kernel as executing scheduler code @@ -128,6 +130,7 @@ _thread_kern_sched(struct sigcontext * scp) /* Save errno. */ _thread_run->error = errno; +#ifdef _THREAD_RUSAGE /* Accumulate time spent */ if (getrusage(RUSAGE_SELF, &ru)) PANIC("Cannot get resource usage"); @@ -137,6 +140,7 @@ _thread_kern_sched(struct sigcontext * scp) timeradd(&tv, &_thread_run->ru_stime, &_thread_run->ru_stime); memcpy(&ru_prev.ru_utime, &ru.ru_utime, sizeof ru_prev.ru_utime); memcpy(&ru_prev.ru_stime, &ru.ru_stime, sizeof ru_prev.ru_stime); +#endif /* _THREAD_RUSAGE */ /* * Enter a the scheduling loop that finds the next thread that is diff --git a/lib/libpthread/uthread/uthread_create.c b/lib/libpthread/uthread/uthread_create.c index 1ed287d2b1b..eef5dab9646 100644 --- a/lib/libpthread/uthread/uthread_create.c +++ b/lib/libpthread/uthread/uthread_create.c @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: uthread_create.c,v 1.6 1999/01/17 23:57:27 d Exp $ + * $OpenBSD: uthread_create.c,v 1.7 1999/02/01 08:23:46 d Exp $ */ #include <errno.h> #include <stdlib.h> @@ -89,8 +89,10 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr, new_thread->stack = stack; new_thread->start_routine = start_routine; new_thread->arg = arg; +#ifdef _THREAD_RUSAGE timerclear(&new_thread->ru_utime); timerclear(&new_thread->ru_stime); +#endif _SPINUNLOCK(&new_thread->lock); new_thread->cancelstate = PTHREAD_CANCEL_ENABLE; diff --git a/lib/libpthread/uthread/uthread_info.c b/lib/libpthread/uthread/uthread_info.c index 53b1e220f1d..3e682752474 100644 --- a/lib/libpthread/uthread/uthread_info.c +++ b/lib/libpthread/uthread/uthread_info.c @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: uthread_info.c,v 1.6 1999/01/17 23:58:10 d Exp $ + * $OpenBSD: uthread_info.c,v 1.7 1999/02/01 08:23:46 d Exp $ */ #include <stdio.h> #include <fcntl.h> @@ -108,8 +108,16 @@ _thread_dump_info(void) /* Display a list of active threads */ - snprintf(s, sizeof s, " %8s%c%-11s %2s %5s %-8s %5s %5s %s\n", - "id", ' ', "state", "pr", "flag", "name", "utime", "stime", + snprintf(s, sizeof s, +#ifdef _THREAD_RUSAGE + " %8s%c%-11s %2s %5s %-8s %5s %5s %s\n", +#else + " %8s%c%-11s %2s %5s %-8s %s\n", +#endif + "id", ' ', "state", "pr", "flag", "name", +#ifdef _THREAD_RUSAGE + "utime", "stime", +#endif "location"); _thread_sys_write(fd, s, strlen(s)); @@ -135,7 +143,11 @@ _thread_dump_info(void) /* Output a record for the current thread: */ s[0] = 0; snprintf(s, sizeof(s), - " %8p%c%-11s %2d %c%c%c%c%c %-8s %5.2f %5.2f %s\n", +#ifdef _THREAD_RUSAGE + " %8p%c%-11s %2d %c%c%c%c%c %-8.8s %5.2f %5.2f %s\n", +#else + " %8p%c%-11s %2d %c%c%c%c%c %-8.8s %s\n", +#endif (void *)pthread, (pthread == _thread_run) ? '*' : ' ', state, @@ -148,10 +160,12 @@ _thread_dump_info(void) (pthread->attr.flags & PTHREAD_INHERIT_SCHED) ? 'I' : ' ', (pthread->attr.flags & PTHREAD_NOFLOAT) ? 'F' : ' ', (pthread->name == NULL) ? "" : pthread->name, +#ifdef _THREAD_RUSAGE pthread->ru_utime.tv_sec + (double)pthread->ru_utime.tv_usec / 1000000.0, pthread->ru_stime.tv_sec + (double)pthread->ru_stime.tv_usec / 1000000.0, +#endif location ); _thread_sys_write(fd, s, strlen(s)); diff --git a/lib/libpthread/uthread/uthread_kern.c b/lib/libpthread/uthread/uthread_kern.c index 8d6f58754e6..88fa55e156c 100644 --- a/lib/libpthread/uthread/uthread_kern.c +++ b/lib/libpthread/uthread/uthread_kern.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: uthread_kern.c,v 1.15 1998/11/15 09:58:26 jb Exp $ - * $OpenBSD: uthread_kern.c,v 1.6 1999/01/17 23:49:49 d Exp $ + * $OpenBSD: uthread_kern.c,v 1.7 1999/02/01 08:23:46 d Exp $ * */ #include <errno.h> @@ -67,8 +67,10 @@ _thread_kern_sched(struct sigcontext * scp) struct timespec ts1; struct timeval tv; struct timeval tv1; +#ifdef _THREAD_RUSAGE struct rusage ru; static struct rusage ru_prev; +#endif /* * Flag the pthread kernel as executing scheduler code @@ -128,6 +130,7 @@ _thread_kern_sched(struct sigcontext * scp) /* Save errno. */ _thread_run->error = errno; +#ifdef _THREAD_RUSAGE /* Accumulate time spent */ if (getrusage(RUSAGE_SELF, &ru)) PANIC("Cannot get resource usage"); @@ -137,6 +140,7 @@ _thread_kern_sched(struct sigcontext * scp) timeradd(&tv, &_thread_run->ru_stime, &_thread_run->ru_stime); memcpy(&ru_prev.ru_utime, &ru.ru_utime, sizeof ru_prev.ru_utime); memcpy(&ru_prev.ru_stime, &ru.ru_stime, sizeof ru_prev.ru_stime); +#endif /* _THREAD_RUSAGE */ /* * Enter a the scheduling loop that finds the next thread that is |