diff options
author | Alexis211 <alexis211@gmail.com> | 2010-03-31 17:26:21 +0200 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2010-03-31 17:26:21 +0200 |
commit | b945eafa126d6a17aa8826a405df7d5d4d999008 (patch) | |
tree | 34b5ba6f0c13b1b35770375f51183a047271a4d4 /src/include | |
parent | ad1ec29070e1ffba7461687cd268e64be06aa78b (diff) | |
download | TCE-b945eafa126d6a17aa8826a405df7d5d4d999008.tar.gz TCE-b945eafa126d6a17aa8826a405df7d5d4d999008.zip |
Shared memory segment manager in userland
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gc/shm.h | 16 | ||||
-rw-r--r-- | src/include/gc/syscall.h | 2 | ||||
-rw-r--r-- | src/include/mutex.h | 15 |
3 files changed, 32 insertions, 1 deletions
diff --git a/src/include/gc/shm.h b/src/include/gc/shm.h new file mode 100644 index 0000000..1a3f0a1 --- /dev/null +++ b/src/include/gc/shm.h @@ -0,0 +1,16 @@ +#ifndef DEF_SHM_H +#define DEF_SHM_H + +#include <gc/syscall.h> + +/* + * This file contains headers for the shared segment mapping manager. + */ + +void* shm_alloc(size_t size); //allocates a spot in shared memory space +void shm_free(void* p); //frees a spot + +void* shm_allocNew(size_t size); //calls shm_alloc, and maps a new segment there +void shm_freeDel(void* p); //unmaps segment and calls shm_free + +#endif diff --git a/src/include/gc/syscall.h b/src/include/gc/syscall.h index f731e10..c93a523 100644 --- a/src/include/gc/syscall.h +++ b/src/include/gc/syscall.h @@ -13,7 +13,7 @@ typedef char int8_t; typedef unsigned size_t; struct user_request { - uint32_t func, params[3]; + uint32_t func, params[3], shmsize[3]; int isBlocking; // 1 : blocking request, 0 : nonblocking request (message) }; diff --git a/src/include/mutex.h b/src/include/mutex.h new file mode 100644 index 0000000..50b5606 --- /dev/null +++ b/src/include/mutex.h @@ -0,0 +1,15 @@ +#ifndef DEF_MUTEX_H +#define DEF_MUTEX_H + +#include <gc/syscall.h> + +#define MUTEX_LOCKED 1 +#define MUTEX_UNLOCKED 0 + +//A mutex is just an uint32_t + +void mutex_lock(uint32_t* mutex); //wait for mutex to be free +int mutex_lockE(uint32_t* mutex); //lock mutex only if free, returns !0 if locked, 0 if was busy +void mutex_unlock(uint32_t* mutex); + +#endif |