X-Git-Url: https://rtime.felk.cvut.cz/gitweb/l4.git/blobdiff_plain/9347d109a9b928929fdc0cedcc1d867bd7e2a918..c02bb3e0b72cd17aaa3cdfb9587d934f1097cc1f:/l4/pkg/moe/server/src/quota.h diff --git a/l4/pkg/moe/server/src/quota.h b/l4/pkg/moe/server/src/quota.h index cde2c3f82..08d0324e9 100644 --- a/l4/pkg/moe/server/src/quota.h +++ b/l4/pkg/moe/server/src/quota.h @@ -40,11 +40,18 @@ public: explicit Quota(size_t limit) : _limit(limit), _used(0) {} bool alloc(size_t s) { - if (_limit && (s > _limit || _used > _limit - s)) + if (_limit && (s > _limit)) return false; + if (_limit && (_used > _limit - s)) + { + GC_gcollect_and_unmap(); + if (_used > _limit - s) + return false; + } + _used += s; - // printf("Q: alloc(%zx) -> %zx\n", s, _used); + //printf("Q: alloc(%zx) -> %zx\n", s, _used); return true; }