[helloworld.c]: #include "app.h" #include void malloc_loop() { for (int i=0; i<100; i++) { int* ptr = malloc(4096); SUCCESS("malloc[%d] done: %p\n", i, ptr); } } void malloc_large() { int* ptr = malloc(4096*100); SUCCESS("malloc[100] done: %p", ptr); } int main(int args, char **argv) { malloc_large(); } --- [kernel.c] if (id == 12 || id == 13 || id == 15) { // ??? // get some free memory; alloc the memory void *a_page = earth->mmu_alloc(); // mtval => faulted VA m_uint32 mtval; asm("csrr %0, mtval" : "=r"(mtval)); // map VA -> a_page earth->mmu_map(curr_pid, (void*)(mtval & ~0xfff), a_page); // rerun mepc // do nothing return; }