X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=Kernel%2Finclude%2Facess.h;h=b8ba67a5c86accc5acac84b34906bd9a28ae90ba;hb=de2ae10743172075f2d527780bdfd890ccddb8e7;hp=993aa1f6ef4b7278c3ce15c491b619a3badd8c10;hpb=321d008781422b7d7137e9acc1ba0e84dec79ff1;p=tpg%2Facess2.git diff --git a/Kernel/include/acess.h b/Kernel/include/acess.h index 993aa1f6..b8ba67a5 100644 --- a/Kernel/include/acess.h +++ b/Kernel/include/acess.h @@ -6,7 +6,8 @@ #define _COMMON_H #define NULL ((void*)0) -#define PACKED __attribute__ ((packed)) +#define PACKED __attribute__((packed)) +#define UNUSED(x) UNUSED_##x __attribute__((unused)) #define offsetof(st, m) ((Uint)((char *)&((st *)(0))->m - (char *)0 )) //#include @@ -20,6 +21,15 @@ typedef int tTID; typedef Uint tUID; typedef Uint tGID; typedef Sint64 tTimestamp; +typedef struct sShortSpinlock tShortSpinlock; +typedef struct sMutex tMutex; + +struct sMutex { + tShortSpinlock Protector; //!< Protector for the lock strucure + struct sThread *volatile Owner; //!< Owner of the lock (set upon getting the lock) + struct sThread *Waiting; //!< Waiting threads + struct sThread *LastWaiting; //!< Waiting threads +}; // --- Helper Macros --- /** @@ -338,18 +348,7 @@ extern Uint rand(void); extern int CallWithArgArray(void *Function, int NArgs, Uint *Args); // --- Heap --- -/** - * \name Heap - * \{ - */ -extern void *malloc(size_t size); -extern void *calloc(size_t num, size_t size); -extern void *realloc(void *ptr, size_t size); -extern void free(void *Ptr); -extern int IsHeap(void *Ptr); -/** - * \} - */ +#include // --- Modules --- /** @@ -405,7 +404,7 @@ extern int Proc_Spawn(char *Path); extern void Threads_Exit(int TID, int Status); extern void Threads_Yield(void); extern void Threads_Sleep(void); -extern void Threads_WakeTID(tTID Thread); +extern int Threads_WakeTID(tTID Thread); extern tPID Threads_GetPID(void); extern tTID Threads_GetTID(void); extern tUID Threads_GetUID(void); @@ -413,6 +412,9 @@ extern tGID Threads_GetGID(void); extern int SpawnTask(tThreadFunction Function, void *Arg); extern Uint *Threads_GetCfgPtr(int Id); extern int Threads_SetName(char *NewName); +extern void Mutex_Acquire(tMutex *Mutex); +extern void Mutex_Release(tMutex *Mutex); +extern int Mutex_IsLocked(tMutex *Mutex); /** * \} */