1
0
mirror of https://github.com/aap/pdp6.git synced 2026-04-09 22:48:13 +00:00

emu: fixed race condition

This commit is contained in:
aap
2019-04-29 16:22:31 +02:00
parent 58e09c73dc
commit c7276abb94
3 changed files with 15 additions and 0 deletions

View File

@@ -845,6 +845,10 @@ renderthread(void *arg)
SDL_TEXTUREACCESS_STREAMING, 1024, 1024);
SDL_SetTextureBlendMode(tex, SDL_BLENDMODE_BLEND);
lock(&initlock);
awaitinit--;
unlock(&initlock);
for(;;){
#ifdef JUSTTESTING
while(SDL_PollEvent(&ev))
@@ -1017,6 +1021,10 @@ makedis(int argc, char *argv[])
t = (Task){ nil, discycle, dis, 20, 0 };
addtask(t);
lock(&initlock);
awaitinit++;
unlock(&initlock);
/* There's a race somewhere here */
threadcreate(renderthread, dis);

View File

@@ -55,6 +55,8 @@ struct SwDigit
static SDL_Window *window;
static SDL_Renderer *renderer;
Lock initlock;
volatile int awaitinit;
Image*
mustloadimg(const char *path)
@@ -903,6 +905,8 @@ void main340(void);
if(apr == nil || tty == nil || ptr == nil || ptp == nil)
err("need APR, TTY, PTR and PTP");
while(awaitinit);
cmdchans[0] = chancreate(sizeof(char*), 1);
cmdchans[1] = chancreate(sizeof(void*), 1);
t = (Task){ nil, readcmdchan, cmdchans, 10, 0 };

View File

@@ -42,6 +42,9 @@ void *rtcthread(void *p);
int dofile(const char *path);
void defaultconfig(void);
extern Lock initlock;
extern volatile int awaitinit;
enum {
MAXPULSE = 20
};