diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2014-08-19 12:02:40 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2014-08-19 12:02:40 -0700 |
commit | 889e4b958e0755eb18f4d545ba4f191d9ea0296c (patch) | |
tree | cf741bd6858a4f4c9eeb5fdbd1c9f4edd578f22c /new.arc | |
parent | 955ecf4a45312c495403aacc0b687a4bc33844ec (diff) | |
download | mu-889e4b958e0755eb18f4d545ba4f191d9ea0296c.tar.gz |
53 - simplest possible allocator: just one word at a time
But with tests this time.
Diffstat (limited to 'new.arc')
-rw-r--r-- | new.arc | 17 |
1 files changed, 17 insertions, 0 deletions
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 |