ref: 98be0723267c03ebbda6c2c9c233209d0af8197b
parent: 597b6cc67544ac7470543213efc3c15ae23ded3c
author: Ori Bernstein <[email protected]>
date: Tue Jul 24 19:20:32 EDT 2012
Tweak the allocator and the hello world test.
--- a/alloc.myr
+++ b/alloc.myr
@@ -15,7 +15,7 @@
const Zslab = 0 castto(slab*)
const Zbin = 0 castto(bin*)
const Pagesz = 4096 /* on the systems this supports, anyways... */
-const Bucketmax = 1024 /* Pagesz / 4; a tolerable balance. */
+const Bucketmax = 1024 /* Pagesz / 8; a balance. */
const Align = 16 /* minimum allocation alignment */
type bucket = struct
@@ -52,13 +52,13 @@
var bkt
if !initdone
- for i = 0; i < buckets.len && (Align << i) < Bucketmax; i++
+ for i = 0; i < buckets.len && (Align << i) <= Bucketmax; i++
bktinit(&buckets[i], Align << i)
;;
initdone = 1
;;
- if (sz < Bucketmax)
+ if (sz <= Bucketmax)
bkt = &buckets[bucketnum(sz)]
-> bktalloc(bkt)
else
@@ -163,7 +163,7 @@
var bktsz
bktsz = Align
- for i = 0; bktsz < Bucketmax; i++
+ for i = 0; bktsz <= Bucketmax; i++
if bktsz >= sz
-> i
;;
--- a/hello.myr
+++ b/hello.myr
@@ -6,7 +6,7 @@
var sz
var i
- for sz = 1; sz < 10000; sz++
+ for sz = 1; sz < 65536; sz *= 2
for i = 0; i < 1024; i++
x[i] = std.bytealloc(sz)
;;