aboutsummaryrefslogtreecommitdiffstats
path: root/utils/sysrepo-plugins/hicn-light/plugin/model/tlock.c
diff options
context:
space:
mode:
authorMasoud Hemmatpour <mhemmatp@cisco.com>2019-03-08 13:40:22 +0100
committerMasoud Hemmatpour <mhemmatp@cisco.com>2019-03-25 15:45:35 +0100
commitc405a5bb3a2299c34f11431be477a228715e66fa (patch)
tree1dabcddbc14dfb010efb22a1547c30f00a03c98e /utils/sysrepo-plugins/hicn-light/plugin/model/tlock.c
parent558581790763815071e9c77e06047e689faf752f (diff)
[HICN-90] adding hicn-light to sysrepo-plugins
Change-Id: Icd92adb21661d33b0cd40ea8c3dd748f0fa97aaf Signed-off-by: Masoud Hemmatpour <mhemmatp@cisco.com> Signed-off-by: Luca Muscariello <lumuscar+fdio@cisco.com> Signed-off-by: Masoud Hemmatpour <mhemmatp@cisco.com>
Diffstat (limited to 'utils/sysrepo-plugins/hicn-light/plugin/model/tlock.c')
-rw-r--r--utils/sysrepo-plugins/hicn-light/plugin/model/tlock.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/utils/sysrepo-plugins/hicn-light/plugin/model/tlock.c b/utils/sysrepo-plugins/hicn-light/plugin/model/tlock.c
new file mode 100644
index 000000000..2f7b11efa
--- /dev/null
+++ b/utils/sysrepo-plugins/hicn-light/plugin/model/tlock.c
@@ -0,0 +1,21 @@
+#include"tlock.h"
+
+
+void Ticket_init ( int Lock_Number , long int init ){
+
+__atomic_store( &En[Lock_Number] , &init , __ATOMIC_SEQ_CST );
+__atomic_store( &De[Lock_Number] , &init , __ATOMIC_SEQ_CST );
+//En[Lock_Number]=init;
+//De[Lock_Number]=init;
+}
+
+void Ticket_Lock(int Lock_Number ){
+
+ int my_ticket = __sync_fetch_and_add(&En[Lock_Number] , 1 );
+ while ( my_ticket != De[ Lock_Number ] ) {};
+
+}
+
+void Ticket_Unlock(int Lock_Number ){
+De[Lock_Number]++;
+}