Skip to content

Commit

Permalink
Heap
Browse files Browse the repository at this point in the history
  • Loading branch information
Kudzu committed Jun 15, 2016
1 parent a4b05c8 commit 95c0021
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Docs/Kernel/Memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ Is portable and simple. Can even be used without VirtMem, but increases time dur

```
MM API
-Allocate new item
+Allocate new item
-Add/remove ref
-Lock/unlock an item
-Force a compact
-Resize a heap item - now way to integrate .NET as it doesnt resize ever (copies instead), but may be useful internally.
Could also plug stringbuilder resize, etc. Possibly even special strings when used internally?
Implicit
-Get pointer
+Get pointer
Internal
-Compact
Expand Down
4 changes: 1 addition & 3 deletions source/Cosmos.Core.Memory.Test/RAT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static public void Init(byte* aStartPtr, Native aSize) {
// We need one status byte for each block.
// Intel blocks are 4k (10 bits). So for 4GB, this means
// 32 - 12 = 20 bits, 1 MB for a RAT for 4GB. 0.025%
Native xRatPageCount = mPageCount / (PageSize - 1) + 1;
Native xRatPageCount = (mPageCount - 1) / PageSize + 1;
Native xRatPageBytes = xRatPageCount * PageSize;
mRAT = mRamStart + mRamSize - xRatPageBytes;
for (Native i = 0; i < xRatPageBytes - xRatPageCount; i++) {
Expand All @@ -66,8 +66,6 @@ static public void Init(byte* aStartPtr, Native aSize) {
mRAT[i] = PageType.RAT;
}

mRAT = Alloc(PageType.RAT, xRatPageCount);

Heap.Init();
}

Expand Down
6 changes: 3 additions & 3 deletions source/Cosmos.Core.Memory.Test/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ unsafe public void TestMethod1() {
Native xRatPages = RAT.GetPageCount(RAT.PageType.RAT);
Assert.IsTrue(xRatPages > 0);

Native xFreePages = RAT.GetPageCount(RAT.PageType.Empty);
var xFreePages = RAT.GetPageCount(RAT.PageType.Empty);
Assert.IsTrue(xFreePages > 0);

var x1 = (Int32*)Heap.Alloc(sizeof(Int32));
xFreePages = RAT.GetPageCount(RAT.PageType.Empty);
Assert.IsTrue(xFreePages > 0);
var xFreePages2 = RAT.GetPageCount(RAT.PageType.Empty);
Assert.IsTrue(xFreePages - xFreePages2 == 1);
}
}
}
Expand Down

0 comments on commit 95c0021

Please sign in to comment.