]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Merge r6157:
authorJulian Seward <jseward@acm.org>
Tue, 17 Oct 2006 02:01:12 +0000 (02:01 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 17 Oct 2006 02:01:12 +0000 (02:01 +0000)
- add extra fields to ThreadOSState to make thread cancellation sort-of
  work on AIX5

- add function VG_(count_runnable_threads)

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6288

coregrind/m_threadstate.c
coregrind/pub_core_threadstate.h

index 1c4633eb7d132f96098bd379fe1ae2c8361c7b79..ebaea8715a99e3042ee4e5ebce0fc0f935202226 100644 (file)
@@ -111,6 +111,19 @@ Int VG_(count_living_threads)(void)
    return count;
 }
 
+/* Return the number of threads in VgTs_Runnable state */
+Int VG_(count_runnable_threads)(void)
+{
+   Int count = 0;
+   ThreadId tid;
+
+   for(tid = 1; tid < VG_N_THREADS; tid++)
+      if (VG_(threads)[tid].status == 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)
@@ -118,7 +131,8 @@ ThreadId VG_(get_lwp_tid)(Int lwp)
    ThreadId tid;
    
    for(tid = 1; tid < VG_N_THREADS; tid++)
-      if (VG_(threads)[tid].status != VgTs_Empty && VG_(threads)[tid].os_state.lwpid == lwp)
+      if (VG_(threads)[tid].status != VgTs_Empty 
+          && VG_(threads)[tid].os_state.lwpid == lwp)
         return tid;
 
    return VG_INVALID_THREADID;
index aa2a9acafd29598c4189d67566771920d7bdd6bf..8b622bc1e46051e074eeef7da2711ca11fb915a4 100644 (file)
@@ -67,8 +67,8 @@ typedef
 typedef
    enum { 
       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 @@ typedef
       Addr valgrind_stack_init_SP; // starting value for SP
 
       /* 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=0, // no cancellation requested
+             Canc_Requested=1, // requested but not actioned
+             Canc_Actioned=2 } // requested and actioned
+           cancel_progress;
+      /* Initial state is False, False, Canc_Normal. */
+#     endif
    }
    ThreadOSstate;
 
@@ -238,6 +252,9 @@ extern Bool VG_(is_exiting)(ThreadId tid);
 /* Return the number of non-dead Threads */
 extern Int VG_(count_living_threads)(void);
 
+/* 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);