|
From: <sv...@va...> - 2006-10-03 20:31:02
|
Author: sewardj
Date: 2006-10-03 21:30:59 +0100 (Tue, 03 Oct 2006)
New Revision: 6157
Log:
- add extra fields to ThreadOSState to make thread cancellation sort-of=20
work on AIX5
- add function VG_(count_runnable_threads)
Modified:
branches/AIX5/coregrind/m_threadstate.c
branches/AIX5/coregrind/pub_core_threadstate.h
Modified: branches/AIX5/coregrind/m_threadstate.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_threadstate.c 2006-10-03 20:26:11 UTC (rev =
6156)
+++ branches/AIX5/coregrind/m_threadstate.c 2006-10-03 20:30:59 UTC (rev =
6157)
@@ -29,6 +29,7 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_vki.h"
#include "pub_core_threadstate.h"
#include "pub_core_libcassert.h"
=20
@@ -110,6 +111,19 @@
return count;
}
=20
+/* Return the number of threads in VgTs_Runnable state */
+Int VG_(count_runnable_threads)(void)
+{
+ Int count =3D 0;
+ ThreadId tid;
+
+ for(tid =3D 1; tid < VG_N_THREADS; tid++)
+ if (VG_(threads)[tid].status =3D=3D VgTs_Runnable)
+ count++;
+
+ return count;
+}
+
/* Given an LWP id (ie, real kernel thread id), find the corresponding
ThreadId */
ThreadId VG_(get_lwp_tid)(Int lwp)
@@ -117,7 +131,8 @@
ThreadId tid;
=20
for(tid =3D 1; tid < VG_N_THREADS; tid++)
- if (VG_(threads)[tid].status !=3D VgTs_Empty && VG_(threads)[tid].=
os_state.lwpid =3D=3D lwp)
+ if (VG_(threads)[tid].status !=3D VgTs_Empty=20
+ && VG_(threads)[tid].os_state.lwpid =3D=3D lwp)
return tid;
=20
return VG_INVALID_THREADID;
Modified: branches/AIX5/coregrind/pub_core_threadstate.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/pub_core_threadstate.h 2006-10-03 20:26:11 UT=
C (rev 6156)
+++ branches/AIX5/coregrind/pub_core_threadstate.h 2006-10-03 20:30:59 UT=
C (rev 6157)
@@ -67,8 +67,8 @@
typedef
enum {=20
VgSrc_None, /* not exiting yet */
- VgSrc_ExitSyscall, /* client called exit(). This is the normal
- route out. */
+ VgSrc_ExitThread, /* just this thread is exiting */
+ VgSrc_ExitProcess, /* entire process is exiting */
VgSrc_FatalSig /* Killed by the default action of a fatal
signal */
}
@@ -121,8 +121,22 @@
Addr valgrind_stack_init_SP; // starting value for SP
=20
/* exit details */
- Int exitcode; // in the case of exitgroup, set by someone else
- Int fatalsig; // fatal signal
+ Word exitcode; // in the case of exitgroup, set by someone else
+ Int fatalsig; // fatal signal
+
+# if defined(VGO_aix5)
+ /* AIX specific fields to make thread cancellation sort-of work */
+ /* What is this thread's current cancellation state a la
+ POSIX (deferred vs async, enable vs disabled) ? */
+ Bool cancel_async; // current cancel mode (async vs deferred)
+ Bool cancel_disabled; // cancellation disabled?
+ /* What's happened so far? */
+ enum { Canc_NoRequest=3D0, // no cancellation requested
+ Canc_Requested=3D1, // requested but not actioned
+ Canc_Actioned=3D2 } // requested and actioned
+ cancel_progress;
+ /* Initial state is False, False, Canc_Normal. */
+# endif
}
ThreadOSstate;
=20
@@ -238,6 +252,9 @@
/* Return the number of non-dead Threads */
extern Int VG_(count_living_threads)(void);
=20
+/* Return the number of threads in VgTs_Runnable state */
+extern Int VG_(count_runnable_threads)(void);
+
/* Given an LWP id (ie, real kernel thread id), find the corresponding
ThreadId */
extern ThreadId VG_(get_lwp_tid)(Int lwpid);
|