Skip to content

Commit

Permalink
Allocate runtime memory based on scenarios
Browse files Browse the repository at this point in the history
Previously, the emulator was configured to allocate 4 GiB of memory
during initialization, which made it unsuitable for environments with
limited memory, such as a virtualized Linux guest configured with 4 GiB.
This commit adjusts the memory mapping requirement to 2^{19} bytes,
sufficient for all known benchmarks.

For configurations with SDL enabled, which support video games like Doom
and Quake, the memory allocation is increased to 4 GiB.

We should develop an adaptive memory mapping mechanism to address this
issue effectively, rather than relying solely on static memory mapping
during initialization.

Reported by ztex <ztex030640417@gmail.com> and
            Yen-Fu Chen <qwe661234@gmail.com>.

Close sysprog21#448
  • Loading branch information
jserv committed Sep 1, 2024
1 parent e804bff commit feca1de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ $(call set-feature, SDL)
ifeq ($(call has, SDL), 1)
OBJS_EXT += syscall_sdl.o
$(OUT)/syscall_sdl.o: CFLAGS += $(shell sdl2-config --cflags)
# 4 GiB of memory is required to run video games.
$(OUT)/main.o: CFLAGS += -DMEM_SIZE=0xFFFFFFFFULL # 2^{32} - 1
LDFLAGS += $(shell sdl2-config --libs) -pthread
LDFLAGS += $(shell pkg-config --libs SDL2_mixer)
endif
Expand Down
5 changes: 3 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,10 @@ static void dump_test_signature(const char *prog_name)
#ifndef CYCLE_PER_STEP
#define CYCLE_PER_STEP 100
#endif
/* MEM_SIZE shall be defined on different runtime */
/* FIXME: MEM_SIZE shall be defined on different runtime */
#ifndef MEM_SIZE
#define MEM_SIZE 0xFFFFFFFFULL /* 2^32 - 1 */
/* Allocate 2^{19} - 1 bytes, which is ample for all known benchmarks. */
#define MEM_SIZE 0x80000
#endif
#define STACK_SIZE 0x1000 /* 4096 */
#define ARGS_OFFSET_SIZE 0x1000 /* 4096 */
Expand Down

0 comments on commit feca1de

Please sign in to comment.