fix rcu spec
[cdsspec-compiler.git] / benchmark / mcs-lock / mcs-lock.h
index 8ff58a23e3d459f7ea43d26158b33974f5775b75..4714567fd1a82b02839897c919a639bed22e96a9 100644 (file)
@@ -3,8 +3,12 @@
 #include <stdatomic.h>
 #include <unrelacy.h>
 
-
-
+#include <spec_lib.h>
+#include <stdlib.h>
+#include <cdsannotate.h>
+#include <specannotation.h>
+#include <model_memory.h>
+#include "common.h" 
 
 struct mcs_node {
        std::atomic<mcs_node *> next;
@@ -31,7 +35,7 @@ public:
                m_tail.store( NULL );
        }
        ~mcs_mutex() {
-               ASSERT( m_tail.load() == NULL );
+               //ASSERT( m_tail.load() == NULL );
        }
 
        // Each thread will have their own guard.
@@ -90,6 +94,7 @@ public:
                        // unlock of pred can see me in the tail before I fill next
 
                        // publish me to previous lock-holder :
+                       // FIXME: detection miss, don't think it's necessary  
                        pred->next.store(me, std::mo_release );
 
                        // (*2) pred not touched any more       
@@ -100,6 +105,8 @@ public:
                        int my_gate = 1;
                        while (my_gate ) {
                                my_gate = me->gate.load(std::mo_acquire);
+                               if (my_gate == 0)
+                                       printf("lock at gate!\n");
                                /**
                                        @Begin
                                        @Commit_point_define_check: my_gate == 0
@@ -125,6 +132,7 @@ public:
        void unlock(guard * I) {
                mcs_node * me = &(I->m_node);
 
+               // FIXME: detection miss, don't think it's necessary
                mcs_node * next = me->next.load(std::mo_acquire);
                if ( next == NULL )
                {
@@ -147,6 +155,7 @@ public:
                        // (*1) catch the race :
                        rl::linear_backoff bo;
                        for(;;) {
+                               // FIXME: detection miss, don't think it's necessary
                                next = me->next.load(std::mo_acquire);
                                if ( next != NULL )
                                        break;