From 2bd33bc33776aa4b72a0ede768d830edc112a8b8 Mon Sep 17 00:00:00 2001 From: kamil Date: Mon, 21 Nov 2016 03:02:34 +0000 Subject: [PATCH] Kill SA thread states (TD_STATE_*) in pthread_dbg and add TD_STATE_DEAD Scheduler Activation types were removed in NetBSD 5.0. Old type set is not matching the new world POSIX threads library. Only TD_STATE_RUNNING, TD_STATE_ZOMBIE are still applicable - keep it. Keep TD_STATE_UNKNOWN as generic unrecognized type. Add new TD_STATE_DEAD one. The TD_STATE_DEAD type is represented by number 6 in the POSIX threads library, but for the sake of compatibility with older software using pthread_dbg - renumber it to 7, as six was reserved for TD_STATE_SUSPENDED. Old removed state types are marked as reserved and unused. Sponsored by --- lib/libpthread_dbg/pthread_dbg.c | 14 +++++++------- lib/libpthread_dbg/pthread_dbg.h | 11 ++++++----- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/libpthread_dbg/pthread_dbg.c b/lib/libpthread_dbg/pthread_dbg.c index 039acb565bff..7204bbee7667 100644 --- a/lib/libpthread_dbg/pthread_dbg.c +++ b/lib/libpthread_dbg/pthread_dbg.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_dbg.c,v 1.48 2016/11/20 21:49:24 kamil Exp $ */ +/* $NetBSD: pthread_dbg.c,v 1.49 2016/11/21 03:02:34 kamil Exp $ */ /*- * Copyright (c) 2002 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include -__RCSID("$NetBSD: pthread_dbg.c,v 1.48 2016/11/20 21:49:24 kamil Exp $"); +__RCSID("$NetBSD: pthread_dbg.c,v 1.49 2016/11/21 03:02:34 kamil Exp $"); #define __EXPOSE_STACK 1 @@ -225,14 +225,12 @@ td_thr_info(td_thread_t *thread, td_thread_info_t *info) case PT_STATE_RUNNING: info->thread_state = TD_STATE_RUNNING; break; -#ifdef XXXLWP - case PT_STATE_SUSPENDED: - info->thread_state = TD_STATE_SUSPENDED; - break; -#endif case PT_STATE_ZOMBIE: info->thread_state = TD_STATE_ZOMBIE; break; + case PT_STATE_DEAD: + info->thread_state = TD_STATE_DEAD; + break; default: info->thread_state = TD_STATE_UNKNOWN; } @@ -306,6 +304,7 @@ td_thr_getregs(td_thread_t *thread, int regset, void *buf) return val; break; case PT_STATE_ZOMBIE: + case PT_STATE_DEAD: default: return TD_ERR_BADTHREAD; } @@ -333,6 +332,7 @@ td_thr_setregs(td_thread_t *thread, int regset, void *buf) return val; break; case PT_STATE_ZOMBIE: + case PT_STATE_DEAD: default: return TD_ERR_BADTHREAD; } diff --git a/lib/libpthread_dbg/pthread_dbg.h b/lib/libpthread_dbg/pthread_dbg.h index 30f1a690d0ec..b4c83d44a2f3 100644 --- a/lib/libpthread_dbg/pthread_dbg.h +++ b/lib/libpthread_dbg/pthread_dbg.h @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_dbg.h,v 1.7 2016/10/22 18:04:40 skrll Exp $ */ +/* $NetBSD: pthread_dbg.h,v 1.8 2016/11/21 03:02:34 kamil Exp $ */ /*- * Copyright (c) 2002 Wasabi Systems, Inc. @@ -77,11 +77,12 @@ typedef struct td_thread_info_st { #define TD_STATE_UNKNOWN 0 #define TD_STATE_RUNNING 1 /* On a processor */ -#define TD_STATE_RUNNABLE 2 /* On a run queue */ -#define TD_STATE_BLOCKED 3 /* Blocked in the kernel */ -#define TD_STATE_SLEEPING 4 /* Blocked on a sync object */ +#define TD_STATE_UNUSED2 2 /* former TD_STATE_RUNNABLE for SA */ +#define TD_STATE_UNUSED3 3 /* former TD_STATE_BLOCKED for SA */ +#define TD_STATE_UNUSED4 4 /* former TD_STATE_SLEEPING for SA */ #define TD_STATE_ZOMBIE 5 -#define TD_STATE_SUSPENDED 6 /* Removed from run queues */ +#define TD_STATE_UNUSED6 6 /* former TD_STATE_SUSPENDED for SA */ +#define TD_STATE_DEAD 7 #define TD_TYPE_UNKNOWN 0 #define TD_TYPE_USER 1