summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2010-04-05 16:56:17 +0200
committerAlexis211 <alexis211@gmail.com>2010-04-05 16:56:17 +0200
commit8d94ae49601e0e4023bcdc35191669b2c24f6c96 (patch)
tree64d625ee6aa5a897666be2768d009b2353ba97d9 /src/library
parentb945eafa126d6a17aa8826a405df7d5d4d999008 (diff)
downloadTCE-8d94ae49601e0e4023bcdc35191669b2c24f6c96.tar.gz
TCE-8d94ae49601e0e4023bcdc35191669b2c24f6c96.zip
More work on IPC.
Diffstat (limited to 'src/library')
-rw-r--r--src/library/Makefile4
-rw-r--r--src/library/gc/server.c (renamed from src/library/gc/object.c)9
-rw-r--r--src/library/gc/shm.c8
-rw-r--r--src/library/std/mutex.c (renamed from src/library/mutex.c)0
4 files changed, 15 insertions, 6 deletions
diff --git a/src/library/Makefile b/src/library/Makefile
index b0dac11..f7161b6 100644
--- a/src/library/Makefile
+++ b/src/library/Makefile
@@ -7,9 +7,9 @@ LD = ld
LDFLAGS = -r
Library = grapes.o
-Objects = gc/syscall.o gc/object.o \
+Objects = gc/syscall.o gc/server.o \
gc/mem.o gc/shm.o \
- mutex.o \
+ std/mutex.o \
start.o
all: $(Library)
diff --git a/src/library/gc/object.c b/src/library/gc/server.c
index 87dafd8..9fd1616 100644
--- a/src/library/gc/object.c
+++ b/src/library/gc/server.c
@@ -109,6 +109,15 @@ Server *srv_create() {
return s;
}
+Server *srv_get(int descriptor) {
+ Server *s = servers;
+ while (s) {
+ if (s->id == descriptor) return s;
+ s = s->next;
+ }
+ return 0;
+}
+
void srv_delete(Server* s) {
//remove s from servers
if (servers == s) {
diff --git a/src/library/gc/shm.c b/src/library/gc/shm.c
index 9e19533..8077352 100644
--- a/src/library/gc/shm.c
+++ b/src/library/gc/shm.c
@@ -26,10 +26,10 @@ void* shm_alloc(size_t size) {
if (blocks == 0) shm_init();
if (size & 0xFFF) size = (size & 0xFFFFF000) + 0x1000;
//go through all blocks, get the one with the closest size
- struct shm_block *block = blocks;
- while (block) {
- if (block->size >= size) break;
- block = block->next;
+ struct shm_block *i = blocks, *block = 0;
+ while (i) {
+ if (i->size >= size && i->is_hole == 1 && i->size < block->size) block = i;
+ i = i->next;
}
if (block == 0) {
mutex_unlock(&tMutex);
diff --git a/src/library/mutex.c b/src/library/std/mutex.c
index ac0ee8f..ac0ee8f 100644
--- a/src/library/mutex.c
+++ b/src/library/std/mutex.c