1
0
mirror of https://github.com/aap/pdp6.git synced 2026-01-11 23:53:31 +00:00

made emulator use less cpu

This commit is contained in:
aap 2021-04-15 20:35:15 +02:00
parent e000f5b5a7
commit d50b59c325
10 changed files with 33 additions and 3 deletions

View File

@ -828,6 +828,7 @@ cli(FILE *in, Channel **c)
void*
cmdthread(void *p)
{
threadname("cli");
cli(stdin, p);
quit(0);
return nil;

View File

@ -835,6 +835,8 @@ renderthread(void *arg)
SDL_Event ev;
SDL_Texture *tex;
threadname("dis340");
dis = arg;
crtinit();
@ -866,12 +868,15 @@ renderthread(void *arg)
SDL_RenderClear(renderer);
render(dis->crt);
// SDL_Delay(30);
SDL_UpdateTexture(tex, nil, dis->crt->pixels, 1024*sizeof(u32));
SDL_RenderCopy(renderer, tex, nil, nil);
SDL_RenderPresent(renderer);
// probably not the best idea to do it like this,
// should perhaps add a time delta to render instead
SDL_Delay(30);
}
return nil;
}

View File

@ -56,6 +56,8 @@ simthread(void *p)
{
Task *t;
threadname("sim");
printf("[simthread] start\n");
for(;;)
for(t = tasks; t; t = t->next){

View File

@ -48,8 +48,10 @@ mount ptr ../code/ptp.out
#mount dx1 ../test/out.dt6
#mount dx1 ../test/test.dt6
mount dx1 ../files/sys6.dtr
##mount dx1 ../system.dtr
#mount dx2 ../test/stuff.dtr
#mount dx2 ../test/spcwar.dtr
mount dx2 ../test/foo.dtr
#mount dx2 ../test/foo.dtr
mount dx2 ../test/aap.dtr
#load -b ../maint/pdp6.part1

View File

@ -1336,6 +1336,7 @@ void main340(void);
// SDL_UnlockSurface(screen);
SDL_RenderPresent(renderer);
SDL_Delay(30);
}
return 0;
}

View File

@ -109,6 +109,9 @@ rtcthread(void *p)
RtcMsg msg;
int loss;
threadname("rtc");
struct timespec slp = { 0, 1*1000*1000 }; // 1ms
loss = 0;
for(;;){
clock_gettime(CLOCK_REALTIME, &now);
@ -133,6 +136,9 @@ rtcthread(void *p)
else
rtcstop(msg.c);
}
// make this thread sleep a bit
nanosleep(&slp, nil);
}
}

View File

@ -1,3 +1,4 @@
#define _GNU_SOURCE // TODO, make portable
#include "threading.h"
#include <assert.h>
@ -208,6 +209,13 @@ threadwait(int id)
pthread_join(gethandle(id), nil);
}
void
threadname(char *name)
{
// TODO: make portable
pthread_setname_np(pthread_self(), name);
}
int
main(int argc, char *argv[])
{

View File

@ -58,3 +58,4 @@ int threadid(void);
void **threaddata(void);
void threadkill(int id);
void threadwait(int id);
void threadname(char *name);

View File

@ -18,5 +18,8 @@ fe6_emu: $(SRC) 6/emu6.c
$(CC) -I6 $(CFLAGS) $(LDFLAGS) -o $@ $^
fe6_fastemu: $(SRC) fastemu.c ../femu/fpdp6.c
$(CC) -I6 $(CFLAGS) $(LDFLAGS) -o $@ $^
feka: $(SRC) ka/real.c
$(XX)gcc -Ika $(CFLAGS) $(LDFLAGS) -o $@ $^

View File

@ -619,7 +619,8 @@ threadmain(int argc, char *argv[])
started = 0;
}
fe_svc();
// usleep(1000);
// this was commented out, why?
usleep(1000);
continue;
}