Skip to content

Conversation

oktal
Copy link

@oktal oktal commented Aug 23, 2013

This patch introduces a new type of lock in GcLock: writelock.

With that comes a new interface :

  • enterWriteShared : mark the beginning of a write-side critical section ;
  • lockWrite : block all writes and waits for all ongoing writes to finish ;
  • writeBarrier : wait for all ongoing writes to finish

Mathieu Stefani added 11 commits July 25, 2013 16:57
rcu_dereference_sym basically calls CMM_ACCESS_ONCE which essentially is the same macro as the ACCESS_ONCE kernel one.
This macro ensures that the compiler won't make any optimization and won't load the given value twice. std::atomic should
do the trick here.
…uarantee that once it's done, the Gc is unlocked.
Conflicts:
	gc/gc_lock.cc
	gc/gc_lock.h
…s. This allows us to block writes when needed
gc/gc_lock.h Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend calling jml's do_abort() before the throw statement. This give us a chance to easily trap the error in gdb if it shows up in DasDB.

@ghost ghost assigned RAttab Aug 23, 2013
@oktal
Copy link
Author

oktal commented Aug 23, 2013

A corollary to our previous lemma (yes I'm fancy being an academic today), if we're
the only thread that can modify the word then unlockWrite's CAS should never fail
because there's no contention. In fact, it shouldn't even need a CAS and a simple
write should do the trick. QED.

I came up with the exact same conclusion. That's why I was throwing an exception. After that, I discovered that the assertion would fail and I decided to get rid of it.

Currently I think the current crop of tests could use a test where you have n threads spamming
lockWrite/unlockWrite non-stop with even more threads spamming enterWrite/exitWrite.

Take a look at gc_test, I have tests for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants