Skip to content

Commit 3f055f3

Browse files
authored
Introduce a enviroment SINGLETHREAD to control emulator thread model (#616)
When SINGLETHREAD environment variable is set, emulator runs in single thread mode to make debug easier.
1 parent 0e63ac8 commit 3f055f3

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ int main() {
8989

9090
// We need to wait until we've actually measured the ADC before proceeding
9191
while(! (priority_ready & (1 << LOW_PRIORITY)))
92-
;
92+
PWR_Sleep();
9393

9494
//Only do this after we've initialized all channel data so the saftey works
9595
PROTOCOL_InitModules();

src/target/common/emu/fltk.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "fltk_resample.h"
3737

3838
bool changed = false;
39+
static bool singlethread = false;
3940

4041
#define USE_OWN_PRINTF 0 //Disable sprintf mappingdue to need for %f
4142
//Windows
@@ -557,6 +558,11 @@ void _ALARMhandler(int sig) {
557558

558559
void CLOCK_Init()
559560
{
561+
singlethread = getenv("SINGLETHREAD") != NULL;
562+
563+
if (singlethread)
564+
return;
565+
560566
timer_callback = NULL;
561567
signal(SIGALRM, _ALARMhandler);
562568
#if 1 //Mac OSX doesn't support posix timers, but does support itimers
@@ -653,6 +659,8 @@ u32 CLOCK_getms()
653659

654660
void PWR_Sleep() {
655661
Fl::wait(0.1);
662+
if (singlethread)
663+
ALARMhandler();
656664
}
657665
void LCD_ForceUpdate() {
658666
if (changed) {

0 commit comments

Comments
 (0)