From f7da5b7dde8b9c342c805edd65e66febf705ed48 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sat, 25 Feb 2023 16:17:03 +0100 Subject: limit thread count to core count --- src/ppusim/sim.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/ppusim/sim.c') diff --git a/src/ppusim/sim.c b/src/ppusim/sim.c index 4226a9b..2816b31 100644 --- a/src/ppusim/sim.c +++ b/src/ppusim/sim.c @@ -1,6 +1,5 @@ #include #include -#include #include #include "main.h" @@ -17,11 +16,15 @@ void hh_ppu_init() { g_hh_window = SDL_CreateWindow("ppusim", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, HH_PPU_SCREEN_WIDTH * HH_PPUSIM_UPSCALE_FACTOR, HH_PPU_SCREEN_HEIGHT * HH_PPUSIM_UPSCALE_FACTOR, SDL_WINDOW_SHOWN); g_hh_renderer = SDL_CreateRenderer(g_hh_window, -1, SDL_RENDERER_ACCELERATED); + g_hh_ppusim_core_count = SDL_GetCPUCount(); + g_hh_ppusim_threads = malloc(sizeof(pthread_t) * g_hh_ppusim_core_count); + g_hh_ppusim_vram = malloc(sizeof(hh_ppu_data_t) * 0xffff); memset(g_hh_ppusim_vram, 0x0000, 0xffff); } void hh_ppu_deinit() { + free(g_hh_ppusim_threads); free(g_hh_ppusim_vram); SDL_DestroyRenderer(g_hh_renderer); -- cgit v1.2.3