amaneureka / AtomOS

A multitasking monolithic Kernel based x86 targeting Operating System written in C# from scratch aiming for high-level implementation of drivers in managed environment.
http://www.atomixos.com
BSD 3-Clause "New" or "Revised" License
1.26k stars 86 forks source link

[SHM] memory out of run exception #1

Open amaneureka opened 8 years ago

amaneureka commented 8 years ago

Handle the case when we are running out of memory

//File: Atomix.Kernel_H.arch.x86.SHM.cs
private static void CreateNew(string aID, int Size)
{
    int NumberOfFrames = (Size / 0x1000) + (Size % 0x1000 == 0 ? 0 : 1);

    var NewChunk = new shm_chunk();
    NewChunk.RefCount = 0;
    NewChunk.Frames = new uint[NumberOfFrames];

    for (int index = 0; index < NumberOfFrames; index++)
    {
        //Allocate New Frame to this guy!
        uint NewFrame = Paging.FirstFreeFrame();
        Paging.SetFrame(NewFrame);
#warning Check If we are not out of run of memory
        NewChunk.Frames[index] = NewFrame;
        //Debug.Write(0x0);
    }
    Nodes.Add(aID, NewChunk);
}
SplittyDev commented 8 years ago

What should happen in the case that not enough free memory is available?

amaneureka commented 8 years ago

That's what the issue is created for. Particularly SHM should not allocate memory from Heap, It should use systemcall sbrk routine but though It has not been implemented so it is allocating through Heap and not caring about memory out of run case,