Skip to content

Commit a2eacf8

Browse files
committed
fix(zaparoo): yield to scheduler instead of usleep during VT wait
switch_to_launcher_vt() ran in the poll cothread. usleep() in libco's cooperative single-thread model sleeps the whole process, so the bounded VT wait stalled both cothreads (no UI/OSD, no poll) for up to 500ms. Replace the fixed usleep retry loop with a wall-clock deadline (GetTimer/CheckTimer) plus scheduler_yield(), keeping the same bound while staying cooperative.
1 parent 01f8cfe commit a2eacf8

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

support/zaparoo/alt_launcher.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "hardware.h"
2222
#include "input.h"
2323
#include "menu.h"
24+
#include "scheduler.h"
2425
#include "shmem.h"
2526
#include "user_io.h"
2627
#include "video.h"
@@ -482,11 +483,15 @@ static void switch_to_launcher_vt(void)
482483

483484
if (ioctl(fd, VT_ACTIVATE, s_vt)) printf("alt_launcher: VT_ACTIVATE fails\n");
484485

485-
for (int i = 0; i < 50; i++)
486+
// Yield to the scheduler rather than usleep() so the poll cothread stays
487+
// cooperative while we wait (bounded) for the VT to become active.
488+
unsigned long deadline = GetTimer(500);
489+
for (;;)
486490
{
487491
struct vt_stat st;
488492
if (!ioctl(fd, VT_GETSTATE, &st) && st.v_active == s_vt) break;
489-
usleep(10000);
493+
if (CheckTimer(deadline)) break;
494+
scheduler_yield();
490495
}
491496

492497
close(fd);

0 commit comments

Comments
 (0)