|
From: <sv...@va...> - 2006-12-17 18:59:01
|
Author: sewardj
Date: 2006-12-17 18:58:55 +0000 (Sun, 17 Dec 2006)
New Revision: 6408
Log:
A naming-only change: rename VG_(set_running) to VG_(acquire_BigLock)
and VG_(set_sleeping) to VG_(release_BigLock). And some other minor
renamings to the thread locking stuff, to make it easier to follow.
Modified:
trunk/coregrind/m_scheduler/priv_sema.h
trunk/coregrind/m_scheduler/scheduler.c
trunk/coregrind/m_scheduler/sema.c
trunk/coregrind/m_signals.c
trunk/coregrind/m_syswrap/syswrap-linux.c
trunk/coregrind/m_syswrap/syswrap-main.c
trunk/coregrind/m_syswrap/syswrap-ppc32-aix5.c
trunk/coregrind/m_syswrap/syswrap-ppc64-aix5.c
trunk/coregrind/pub_core_scheduler.h
Modified: trunk/coregrind/m_scheduler/priv_sema.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
--- trunk/coregrind/m_scheduler/priv_sema.h 2006-12-17 17:40:06 UTC (rev =
6407)
+++ trunk/coregrind/m_scheduler/priv_sema.h 2006-12-17 18:58:55 UTC (rev =
6408)
@@ -32,10 +32,9 @@
#define __PRIV_SEMA_H
=20
/* Not really a semaphore, but use a pipe for a token-passing scheme */
-/* Not really a semaphore, but use a pipe for a token-passing scheme */
typedef struct {
Int pipe[2];
- Int owner_thread; /* who currently has it */
+ Int owner_lwpid; /* who currently has it */
} vg_sema_t;
=20
// Nb: this may be OS-specific, but let's not factor it out until we
Modified: trunk/coregrind/m_scheduler/scheduler.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
--- trunk/coregrind/m_scheduler/scheduler.c 2006-12-17 17:40:06 UTC (rev =
6407)
+++ trunk/coregrind/m_scheduler/scheduler.c 2006-12-17 18:58:55 UTC (rev =
6408)
@@ -38,13 +38,13 @@
There are no extra threads.
=20
The main difference is that Valgrind only allows one client thread
- to run at once. This is controlled with the VCPU semaphore,
- "run_sema". Any time a thread wants to run client code or
+ to run at once. This is controlled with the CPU Big Lock,
+ "the_BigLock". Any time a thread wants to run client code or
manipulate any shared state (which is anything other than its own
- ThreadState entry), it must hold the run_sema.
+ ThreadState entry), it must hold the_BigLock.
=20
When a thread is about to block in a blocking syscall, it releases
- run_sema, and re-takes it when it becomes runnable again (either
+ the_BigLock, and re-takes it when it becomes runnable again (either
because the syscall finished, or we took a signal).
=20
VG_(scheduler) therefore runs in each thread. It returns only when
@@ -135,7 +135,7 @@
}
=20
/* CPU semaphore, so that threads can run exclusively */
-static vg_sema_t run_sema;
+static vg_sema_t the_BigLock;
=20
=20
/* ---------------------------------------------------------------------
@@ -189,14 +189,14 @@
}
=20
/*=20
- Mark a thread as Runnable. This will block until the run_sema is
+ Mark a thread as Runnable. This will block until the_BigLock is
available, so that we get exclusive access to all the shared
- structures and the CPU. Up until we get the sema, we must not
+ structures and the CPU. Up until we get the_BigLock, we must not
touch any shared state.
=20
When this returns, we'll actually be running.
*/
-void VG_(set_running)(ThreadId tid, HChar* who)
+void VG_(acquire_BigLock)(ThreadId tid, HChar* who)
{
ThreadState *tst;
=20
@@ -209,10 +209,10 @@
}
#endif
=20
- /* First, acquire the lock. We can't do anything else safely prior
- to this point. Even doing debug printing prior to this point
- is, technically, wrong. */
- ML_(sema_down)(&run_sema);
+ /* First, acquire the_BigLock. We can't do anything else safely
+ prior to this point. Even doing debug printing prior to this
+ point is, technically, wrong. */
+ ML_(sema_down)(&the_BigLock);
=20
tst =3D VG_(get_ThreadState)(tid);
=20
@@ -246,7 +246,7 @@
but it may mean that we remain in a Runnable state and we're just
yielding the CPU to another thread).
*/
-void VG_(set_sleeping)(ThreadId tid, ThreadStatus sleepstate, HChar* who=
)
+void VG_(release_BigLock)(ThreadId tid, ThreadStatus sleepstate, HChar* =
who)
{
ThreadState *tst =3D VG_(get_ThreadState)(tid);
=20
@@ -268,9 +268,9 @@
print_sched_event(tid, buf);
}
=20
- /* Release the run_sema; this will reschedule any runnable
+ /* Release the_BigLock; this will reschedule any runnable
thread. */
- ML_(sema_up)(&run_sema);
+ ML_(sema_up)(&the_BigLock);
}
=20
/* Clear out the ThreadState and release the semaphore. Leaves the
@@ -291,7 +291,7 @@
if (VG_(clo_trace_sched))
print_sched_event(tid, "release lock in VG_(exit_thread)");
=20
- ML_(sema_up)(&run_sema);
+ ML_(sema_up)(&the_BigLock);
}
=20
/* If 'tid' is blocked in a syscall, send it SIGVGKILL so as to get it
@@ -321,14 +321,14 @@
vg_assert(tid !=3D VG_INVALID_THREADID);
vg_assert(VG_(threads)[tid].os_state.lwpid =3D=3D VG_(gettid)());
=20
- VG_(set_sleeping)(tid, VgTs_Yielding, "VG_(vg_yield)");
+ VG_(release_BigLock)(tid, VgTs_Yielding, "VG_(vg_yield)");
=20
/*=20
Tell the kernel we're yielding.
*/
VG_(do_syscall0)(__NR_sched_yield);
=20
- VG_(set_running)(tid, "VG_(vg_yield)");
+ VG_(acquire_BigLock)(tid, "VG_(vg_yield)");
}
=20
=20
@@ -413,9 +413,9 @@
would be too hard to try to re-number the thread and relocate the =
=20
thread state down to VG_(threads)[1]. =
=20
=
=20
- This function also needs to reinitialize the run_sema, since =
=20
- otherwise we may end up sharing its state with the parent, which =
=20
- would be deeply confusing. =
=20
+ This function also needs to reinitialize the_BigLock, since
+ otherwise we may end up sharing its state with the parent, which
+ would be deeply confusing.
*/ =20
static void sched_fork_cleanup(ThreadId me)
{
@@ -435,9 +435,9 @@
}
=20
/* re-init and take the sema */
- ML_(sema_deinit)(&run_sema);
- ML_(sema_init)(&run_sema);
- ML_(sema_down)(&run_sema);
+ ML_(sema_deinit)(&the_BigLock);
+ ML_(sema_init)(&the_BigLock);
+ ML_(sema_down)(&the_BigLock);
}
=20
=20
@@ -457,7 +457,7 @@
vg_assert(VG_IS_PAGE_ALIGNED(clstack_end+1));
vg_assert(VG_IS_PAGE_ALIGNED(clstack_size));
=20
- ML_(sema_init)(&run_sema);
+ ML_(sema_init)(&the_BigLock);
=20
for (i =3D 0 /* NB; not 1 */; i < VG_N_THREADS; i++) {
/* Paranoia .. completely zero it out. */
@@ -813,7 +813,7 @@
/*=20
Run a thread until it wants to exit.
=20
- We assume that the caller has already called VG_(set_running) for
+ We assume that the caller has already called VG_(acquire_BigLock) for
us, so we own the VCPU. Also, all signals are blocked.
*/
VgSchedReturnCode VG_(scheduler) ( ThreadId tid )
@@ -860,8 +860,8 @@
/* 3 Aug 06: doing sys__nsleep works but crashes some apps.
sys_yield also helps the problem, whilst not crashing apps. =
*/
=20
- VG_(set_sleeping)(tid, VgTs_Yielding,=20
- "VG_(scheduler):timeslice");
+ VG_(release_BigLock)(tid, VgTs_Yielding,=20
+ "VG_(scheduler):timeslice");
/* ------------ now we don't have The Lock ------------ */
=20
# if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
@@ -878,7 +878,7 @@
}
# endif
=20
- VG_(set_running)(tid, "VG_(scheduler):timeslice");
+ VG_(acquire_BigLock)(tid, "VG_(scheduler):timeslice");
/* ------------ now we do have The Lock ------------ */
=20
/* OK, do some relatively expensive housekeeping stuff */
@@ -1387,7 +1387,7 @@
if (!VG_(is_running_thread)(tid)) {
VG_(message)(Vg_DebugMsg,
"Thread %d is supposed to be running, "
- "but doesn't own run_sema (owned by %d)\n",=20
+ "but doesn't own the_BigLock (owned by %d)\n",=20
tid, VG_(running_tid));
bad =3D True;
}
@@ -1399,9 +1399,9 @@
bad =3D True;
}
=20
- if (lwpid !=3D run_sema.owner_thread) {
+ if (lwpid !=3D the_BigLock.owner_lwpid) {
VG_(message)(Vg_DebugMsg,
- "Thread %d doesn't own the run_sema\n",
+ "Thread (LWPID) %d doesn't own the_BigLock\n",
tid);
bad =3D True;
}
Modified: trunk/coregrind/m_scheduler/sema.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
--- trunk/coregrind/m_scheduler/sema.c 2006-12-17 17:40:06 UTC (rev 6407)
+++ trunk/coregrind/m_scheduler/sema.c 2006-12-17 18:58:55 UTC (rev 6408)
@@ -65,7 +65,7 @@
sema->pipe[1]);
vg_assert(sema->pipe[0] !=3D sema->pipe[1]);
=20
- sema->owner_thread =3D -1;
+ sema->owner_lwpid =3D -1;
=20
/* create initial token */
sema_char =3D 'A';
@@ -78,12 +78,12 @@
=20
void ML_(sema_deinit)(vg_sema_t *sema)
{
- vg_assert(sema->owner_thread !=3D -1); /* must be initialised */
+ vg_assert(sema->owner_lwpid !=3D -1); /* must be initialised */
vg_assert(sema->pipe[0] !=3D sema->pipe[1]);
VG_(close)(sema->pipe[0]);
VG_(close)(sema->pipe[1]);
sema->pipe[0] =3D sema->pipe[1] =3D -1;
- sema->owner_thread =3D -1;
+ sema->owner_lwpid =3D -1;
}
=20
/* get a token */
@@ -93,7 +93,7 @@
Int ret;
Int lwpid =3D VG_(gettid)();
=20
- vg_assert(sema->owner_thread !=3D lwpid); /* can't have it already */
+ vg_assert(sema->owner_lwpid !=3D lwpid); /* can't have it already */
vg_assert(sema->pipe[0] !=3D sema->pipe[1]);
=20
again:
@@ -113,7 +113,7 @@
=20
if (sema_char =3D=3D 'Z') sema_char =3D 'A'; else sema_char++;
=20
- sema->owner_thread =3D lwpid;
+ sema->owner_lwpid =3D lwpid;
}
=20
/* put token back */
@@ -123,11 +123,11 @@
Char buf[2];
buf[0] =3D sema_char;=20
buf[1] =3D 0;
- vg_assert(sema->owner_thread !=3D -1); /* must be initialised */
+ vg_assert(sema->owner_lwpid !=3D -1); /* must be initialised */
vg_assert(sema->pipe[0] !=3D sema->pipe[1]);
- vg_assert(sema->owner_thread =3D=3D VG_(gettid)()); /* must have it *=
/
+ vg_assert(sema->owner_lwpid =3D=3D VG_(gettid)()); /* must have it */
=20
- sema->owner_thread =3D 0;
+ sema->owner_lwpid =3D 0;
=20
ret =3D VG_(write)(sema->pipe[1], buf, 1);
=20
Modified: trunk/coregrind/m_signals.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
--- trunk/coregrind/m_signals.c 2006-12-17 17:40:06 UTC (rev 6407)
+++ trunk/coregrind/m_signals.c 2006-12-17 18:58:55 UTC (rev 6408)
@@ -1589,7 +1589,7 @@
vg_assert(tst->status =3D=3D VgTs_WaitSys);
=20
/* The thread isn't currently running, make it so before going on */
- VG_(set_running)(tid, "async_signalhandler");
+ VG_(acquire_BigLock)(tid, "async_signalhandler");
=20
/* Update thread state properly */
VG_(fixup_guest_state_after_syscall_interrupted)(
@@ -1915,7 +1915,7 @@
VG_(message)(Vg_DebugMsg,=20
"sigvgkill for lwp %d tid %d", VG_(gettid)(), tid);
=20
- VG_(set_running)(tid, "sigvgkill_handler");
+ VG_(acquire_BigLock)(tid, "sigvgkill_handler");
=20
vg_assert(signo =3D=3D VG_SIGVGKILL);
vg_assert(si->si_signo =3D=3D signo);
Modified: trunk/coregrind/m_syswrap/syswrap-linux.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
--- trunk/coregrind/m_syswrap/syswrap-linux.c 2006-12-17 17:40:06 UTC (re=
v 6407)
+++ trunk/coregrind/m_syswrap/syswrap-linux.c 2006-12-17 18:58:55 UTC (re=
v 6408)
@@ -71,7 +71,7 @@
vg_assert(tst->status =3D=3D VgTs_Init);
=20
/* make sure we get the CPU lock before doing anything significant */
- VG_(set_running)(tid, "thread_wrapper(starting new thread)");
+ VG_(acquire_BigLock)(tid, "thread_wrapper(starting new thread)");
=20
if (0)
VG_(printf)("thread tid %d started: stack =3D %p\n",
Modified: trunk/coregrind/m_syswrap/syswrap-main.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
--- trunk/coregrind/m_syswrap/syswrap-main.c 2006-12-17 17:40:06 UTC (rev=
6407)
+++ trunk/coregrind/m_syswrap/syswrap-main.c 2006-12-17 18:58:55 UTC (rev=
6408)
@@ -38,7 +38,7 @@
#include "pub_core_libcprint.h"
#include "pub_core_libcproc.h" // For VG_(getpid)()
#include "pub_core_libcsignal.h"
-#include "pub_core_scheduler.h" // For VG_(set_sleeping), VG_(set_ru=
nning),
+#include "pub_core_scheduler.h" // For VG_({acquire,release}_BigLock=
),
// and VG_(vg_yield)
#include "pub_core_stacktrace.h" // For VG_(get_and_pp_StackTrace)()
#include "pub_core_tooliface.h"
@@ -915,7 +915,7 @@
putSyscallArgsIntoGuestState( &sci->args, &tst->arch.vex );
=20
/* Drop the lock */
- VG_(set_sleeping)(tid, VgTs_WaitSys, "VG_(client_syscall)[async=
]");
+ VG_(release_BigLock)(tid, VgTs_WaitSys, "VG_(client_syscall)[as=
ync]");
=20
/* Do the call, which operates directly on the guest state,
not on our abstracted copies of the args/result. */
@@ -930,7 +930,7 @@
to the scheduler. */
=20
/* Reacquire the lock */
- VG_(set_running)(tid, "VG_(client_syscall)[async]");
+ VG_(acquire_BigLock)(tid, "VG_(client_syscall)[async]");
=20
/* Even more impedance matching. Extract the syscall status
from the guest state. */
Modified: trunk/coregrind/m_syswrap/syswrap-ppc32-aix5.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
--- trunk/coregrind/m_syswrap/syswrap-ppc32-aix5.c 2006-12-17 17:40:06 UT=
C (rev 6407)
+++ trunk/coregrind/m_syswrap/syswrap-ppc32-aix5.c 2006-12-17 18:58:55 UT=
C (rev 6408)
@@ -94,7 +94,7 @@
vg_assert(tst->status =3D=3D VgTs_Init);
=20
/* make sure we get the CPU lock before doing anything significant */
- VG_(set_running)(tid, "thread_wrapper(starting new thread)");
+ VG_(acquire_BigLock)(tid, "thread_wrapper(starting new thread)");
=20
if (0)
VG_(printf)("thread tid %d started: stack =3D %p\n",
Modified: trunk/coregrind/m_syswrap/syswrap-ppc64-aix5.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
--- trunk/coregrind/m_syswrap/syswrap-ppc64-aix5.c 2006-12-17 17:40:06 UT=
C (rev 6407)
+++ trunk/coregrind/m_syswrap/syswrap-ppc64-aix5.c 2006-12-17 18:58:55 UT=
C (rev 6408)
@@ -94,7 +94,7 @@
vg_assert(tst->status =3D=3D VgTs_Init);
=20
/* make sure we get the CPU lock before doing anything significant */
- VG_(set_running)(tid, "thread_wrapper(starting new thread)");
+ VG_(acquire_BigLock)(tid, "thread_wrapper(starting new thread)");
=20
if (0)
VG_(printf)("thread tid %d started: stack =3D %p\n",
Modified: trunk/coregrind/pub_core_scheduler.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
--- trunk/coregrind/pub_core_scheduler.h 2006-12-17 17:40:06 UTC (rev 640=
7)
+++ trunk/coregrind/pub_core_scheduler.h 2006-12-17 18:58:55 UTC (rev 640=
8)
@@ -57,7 +57,7 @@
thread state to VgTs_Runnable, and the thread will attempt to take
the CPU lock. By the time it returns, tid will be the running
thread. */
-extern void VG_(set_running) ( ThreadId tid, HChar* who );
+extern void VG_(acquire_BigLock) ( ThreadId tid, HChar* who );
=20
/* Set a thread into a sleeping state. Before the call, the thread
must be runnable, and holding the CPU lock. When this call
@@ -67,7 +67,7 @@
caller must be careful not to touch any shared state. It is also
the caller's responsibility to actually block until the thread is
ready to run again. */
-extern void VG_(set_sleeping) ( ThreadId tid, ThreadStatus state, HChar*=
who );
+extern void VG_(release_BigLock) ( ThreadId tid, ThreadStatus state, HCh=
ar* who );
=20
/* Yield the CPU for a while */
extern void VG_(vg_yield)(void);
|