小编Aar*_*V77的帖子

内存分配在操作系统的最低级别如何发生?

我试图弄清楚如何在操作系统的最低级别分配内存。据我所知,操作系统只是在对可用内存和不可用内存进行记账,而C编程语言将在最低级别进行分配。

因此,第一个示例是我作为一个简单的内存分配系统想到的,然后从以下资源中获取了一个示例:https : //github.com/levex/osdev

示例1:

    struct heap_elements {
        int start_address;
        int end_address;
        int size;
        int reservation;
    };

    struct heap_elements heap[25];

    // Write len copies of val into dest.
    void memset(int *dest, int val, int len)
    {
        int *temp = (int *)dest;
        for ( ; len != 0; len--) *temp++ = val;
    }

    /*
    * This function will take a source and destination and copy n amount
    * - of bytes from the source to the destination address. 
    */ …
Run Code Online (Sandbox Code Playgroud)

c memory x86 operating-system memory-management

1
推荐指数
1
解决办法
118
查看次数

标签 统计

c ×1

memory ×1

memory-management ×1

operating-system ×1

x86 ×1