rt: Remove lock_held_by_current_thread

This commit is contained in:
Brian Anderson 2012-03-18 15:59:00 -07:00
parent e4af1ca065
commit b247de6458
9 changed files with 0 additions and 75 deletions

View File

@ -389,34 +389,6 @@
fun:uv_loop_delete
}
{
lock_and_signal-probably-threadsafe-access-outside-of-lock
Helgrind:Race
fun:_ZN15lock_and_signal27lock_held_by_current_threadEv
...
}
{
lock_and_signal-probably-threadsafe-access-outside-of-lock2
Helgrind:Race
fun:_ZN15lock_and_signal6unlockEv
...
}
{
lock_and_signal-probably-threadsafe-access-outside-of-lock3
Helgrind:Race
fun:_ZN15lock_and_signal4lockEv
...
}
{
lock_and_signal-probably-threadsafe-access-outside-of-lock4
Helgrind:Race
fun:_ZN15lock_and_signal4waitEv
...
}
{
uv-async-send-does-racy-things
Helgrind:Race

View File

@ -62,7 +62,6 @@ void rust_kernel::free(void *mem) {
rust_sched_id
rust_kernel::create_scheduler(size_t num_threads) {
I(this, !sched_lock.lock_held_by_current_thread());
rust_sched_id id;
rust_scheduler *sched;
{
@ -81,7 +80,6 @@ rust_kernel::create_scheduler(size_t num_threads) {
rust_scheduler *
rust_kernel::get_scheduler_by_id(rust_sched_id id) {
I(this, !sched_lock.lock_held_by_current_thread());
scoped_lock with(sched_lock);
sched_map::iterator iter = sched_table.find(id);
if (iter != sched_table.end()) {
@ -93,7 +91,6 @@ rust_kernel::get_scheduler_by_id(rust_sched_id id) {
void
rust_kernel::release_scheduler_id(rust_sched_id id) {
I(this, !sched_lock.lock_held_by_current_thread());
scoped_lock with(sched_lock);
// This list will most likely only ever have a single element in it, but
// it's an actual list because we could potentially get here multiple
@ -111,7 +108,6 @@ them then we can see valgrind errors due to un-freed pthread memory.
int
rust_kernel::wait_for_schedulers()
{
I(this, !sched_lock.lock_held_by_current_thread());
scoped_lock with(sched_lock);
while (!sched_table.empty()) {
while (!join_list.empty()) {

View File

@ -55,7 +55,6 @@ void rust_port::end_detach() {
}
void rust_port::send(void *sptr) {
I(task->thread, !lock.lock_held_by_current_thread());
bool did_rendezvous = false;
{
scoped_lock with(lock);
@ -88,8 +87,6 @@ void rust_port::send(void *sptr) {
}
void rust_port::receive(void *dptr, uintptr_t *yield) {
I(task->thread, !lock.lock_held_by_current_thread());
LOG(task, comm, "port: 0x%" PRIxPTR ", dptr: 0x%" PRIxPTR
", size: 0x%" PRIxPTR,
(uintptr_t) this, (uintptr_t) dptr, unit_sz);
@ -122,7 +119,6 @@ void rust_port::receive(void *dptr, uintptr_t *yield) {
}
size_t rust_port::size() {
I(task->thread, !lock.lock_held_by_current_thread());
scoped_lock with(lock);
return buffer.size();
}

View File

@ -69,9 +69,6 @@ void
rust_port_selector::msg_sent_on(rust_port *port) {
rust_task *task = port->task;
I(task->thread, !port->lock.lock_held_by_current_thread());
I(task->thread, !rendezvous_lock.lock_held_by_current_thread());
// Prevent two ports from trying to wake up the task
// simultaneously
scoped_lock with(rendezvous_lock);

View File

@ -133,7 +133,6 @@ rust_scheduler::number_of_threads() {
void
rust_scheduler::release_task_thread() {
I(this, !lock.lock_held_by_current_thread());
uintptr_t new_live_threads;
{
scoped_lock with(lock);

View File

@ -242,7 +242,6 @@ rust_task::must_fail_from_being_killed() {
bool
rust_task::must_fail_from_being_killed_unlocked() {
I(thread, kill_lock.lock_held_by_current_thread());
return killed && !reentered_rust_stack;
}

View File

@ -121,8 +121,6 @@ rust_task_thread::number_of_live_tasks() {
*/
void
rust_task_thread::reap_dead_tasks() {
I(this, lock.lock_held_by_current_thread());
if (dead_tasks.length() == 0) {
return;
}
@ -358,7 +356,6 @@ rust_task_thread::place_task_in_tls(rust_task *task) {
void
rust_task_thread::exit() {
A(this, !lock.lock_held_by_current_thread(), "Shouldn't have lock");
scoped_lock with(lock);
should_exit = true;
lock.signal();

View File

@ -10,13 +10,8 @@
#include "lock_and_signal.h"
// FIXME: This is not a portable way of specifying an invalid pthread_t
#define INVALID_THREAD 0
#if defined(__WIN32__)
lock_and_signal::lock_and_signal()
: _holding_thread(INVALID_THREAD)
{
_event = CreateEvent(NULL, FALSE, FALSE, NULL);
@ -35,7 +30,6 @@ lock_and_signal::lock_and_signal()
#else
lock_and_signal::lock_and_signal()
: _holding_thread(INVALID_THREAD)
{
CHECKED(pthread_cond_init(&_cond, NULL));
CHECKED(pthread_mutex_init(&_mutex, NULL));
@ -53,19 +47,14 @@ lock_and_signal::~lock_and_signal() {
}
void lock_and_signal::lock() {
assert(!lock_held_by_current_thread());
#if defined(__WIN32__)
EnterCriticalSection(&_cs);
_holding_thread = GetCurrentThreadId();
#else
CHECKED(pthread_mutex_lock(&_mutex));
_holding_thread = pthread_self();
#endif
}
void lock_and_signal::unlock() {
assert(lock_held_by_current_thread());
_holding_thread = INVALID_THREAD;
#if defined(__WIN32__)
LeaveCriticalSection(&_cs);
#else
@ -77,18 +66,12 @@ void lock_and_signal::unlock() {
* Wait indefinitely until condition is signaled.
*/
void lock_and_signal::wait() {
assert(lock_held_by_current_thread());
_holding_thread = INVALID_THREAD;
#if defined(__WIN32__)
LeaveCriticalSection(&_cs);
WaitForSingleObject(_event, INFINITE);
EnterCriticalSection(&_cs);
assert(_holding_thread == INVALID_THREAD);
_holding_thread = GetCurrentThreadId();
#else
CHECKED(pthread_cond_wait(&_cond, &_mutex));
assert(_holding_thread == INVALID_THREAD);
_holding_thread = pthread_self();
#endif
}
@ -103,15 +86,6 @@ void lock_and_signal::signal() {
#endif
}
bool lock_and_signal::lock_held_by_current_thread()
{
#if defined(__WIN32__)
return _holding_thread == GetCurrentThreadId();
#else
return pthread_equal(_holding_thread, pthread_self());
#endif
}
scoped_lock::scoped_lock(lock_and_signal &lock)
: lock(lock)
{

View File

@ -6,12 +6,9 @@ class lock_and_signal {
#if defined(__WIN32__)
HANDLE _event;
CRITICAL_SECTION _cs;
DWORD _holding_thread;
#else
pthread_cond_t _cond;
pthread_mutex_t _mutex;
pthread_t _holding_thread;
#endif
public:
@ -22,8 +19,6 @@ public:
void unlock();
void wait();
void signal();
bool lock_held_by_current_thread();
};
class scoped_lock {