From c405a5bb3a2299c34f11431be477a228715e66fa Mon Sep 17 00:00:00 2001 From: Masoud Hemmatpour Date: Fri, 8 Mar 2019 13:40:22 +0100 Subject: [HICN-90] adding hicn-light to sysrepo-plugins Change-Id: Icd92adb21661d33b0cd40ea8c3dd748f0fa97aaf Signed-off-by: Masoud Hemmatpour Signed-off-by: Luca Muscariello Signed-off-by: Masoud Hemmatpour --- .../sysrepo-plugins/hicn-light/plugin/model/tlock.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 utils/sysrepo-plugins/hicn-light/plugin/model/tlock.c (limited to 'utils/sysrepo-plugins/hicn-light/plugin/model/tlock.c') 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]++; +} -- cgit 1.2.3-korg