From 889e4b958e0755eb18f4d545ba4f191d9ea0296c Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 19 Aug 2014 12:02:40 -0700 Subject: 53 - simplest possible allocator: just one word at a time But with tests this time. --- new.arc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 new.arc (limited to 'new.arc') diff --git a/new.arc b/new.arc new file mode 100644 index 00000000..0f0b4b71 --- /dev/null +++ b/new.arc @@ -0,0 +1,17 @@ +;; simple slab allocator. Intended only to carve out isolated memory for +;; different threads/routines as they request. + +(on-init + ((Root_allocator_pointer location) <- literal 1000) ; 1-1000 reserved +) + +(init-fn new + ((2 integer-address) <- copy (Root_allocator_pointer integer)) + ((3 integer) <- literal 1) + ((Root_allocator_pointer integer) <- add (Root_allocator_pointer integer) (3 integer)) + (reply (2 integer-address))) +; tests to express: +; every call increments the pointer +; no other function can increment the pointer +; no later clause can increment the pointer after this base clause +; multiple threads/routines can't call the allocator at once -- cgit 1.4.1-2-gfad0