diff --git a/frontend/stepper/abstract_runner.ts b/frontend/stepper/abstract_runner.ts index 7eefa5cc..acd30e2b 100644 --- a/frontend/stepper/abstract_runner.ts +++ b/frontend/stepper/abstract_runner.ts @@ -164,10 +164,10 @@ export default abstract class AbstractRunner { log.getLogger('multithread').debug('[multithread] default create new thread'); } - public registerNewThread(threadData: any): number { - log.getLogger('multithread').debug('[multithread] register new thread', threadData, threadData.length); + public registerNewThread(threadData: any = null): number { + log.getLogger('multithread').debug('[multithread] register new thread', threadData); const newThreadId = this.maxThreadId; - this.threads[newThreadId] = [...threadData]; + this.threads[newThreadId] = threadData ? [...threadData] : null; this.maxThreadId++; return newThreadId; @@ -195,6 +195,7 @@ export default abstract class AbstractRunner { } public swapCurrentThreadId(newThreadId: number): void { + this.currentThreadId = newThreadId; } public currentThreadFinished(newThreadId: number): void { diff --git a/frontend/stepper/c/unix_runner.ts b/frontend/stepper/c/unix_runner.ts index 83e3ddee..835ab00a 100644 --- a/frontend/stepper/c/unix_runner.ts +++ b/frontend/stepper/c/unix_runner.ts @@ -49,6 +49,8 @@ export default class UnixRunner extends AbstractRunner { } public async programInitialization(stepperContext: StepperContext): Promise { + this.registerNewThread(); + while (!inUserCode(stepperContext.state)) { /* Mutate the stepper context to advance execution by a single step. */ const effects = C.step(stepperContext.state.programState);