klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

kmutex.h (896B)


      1 /*
      2 ** kmutex.h
      3 ** Kernel Libraries
      4 ** See Copyright Notice in klisp.h
      5 */
      6 
      7 #ifndef kmutex_h
      8 #define kmutex_h
      9 
     10 #include "kobject.h"
     11 #include "kstate.h"
     12 
     13 TValue kmake_mutex(klisp_State *K);
     14 void klispX_free(klisp_State *K, Mutex *mutex);
     15 
     16 /* LOCK: these functions require that the calling code has 
     17    acquired the GIL exactly once previous to the call and
     18    they may temporarily release it to avoid deadlocks */
     19 /* All of these do the required checks of owernship */
     20 void kmutex_lock(klisp_State *K, TValue mutex);
     21 void kmutex_unlock(klisp_State *K, TValue mutex);
     22 bool kmutex_trylock(klisp_State *K, TValue mutex);
     23 
     24 #define kmutex_is_owned(m_) (ttisthread(tv2mutex(m_)->owner))
     25 #define kmutex_owner(m_) (tv2mutex(m_)->owner)
     26 #define kmutex_mutex(m_) (tv2mutex(m_)->mutex)
     27 #define kmutex_count(m_) (tv2mutex(m_)->count)
     28 
     29 // #define KMUTEX_MAX_COUNT UINT32_MAX
     30 #define KMUTEX_MAX_COUNT 255
     31 
     32 #endif