Skip to main content

Module thread

Module thread 

Source
Expand description

Guest thread support: host pthread spawn + bsdthread_* helpers.

Model (micro / clean-room):

  • bsdthread_register stores the libpthread start trampoline VA.
  • bsdthread_create spawns a host thread that jumps into that trampoline with Darwin _pthread_start register convention (x0–x3).
  • bsdthread_terminate switches back to a saved host stack then pthread_exits this host thread only (never exit on the guest stack).
  • Guest pthread_join completion (done + futex wake) is published from the host stack so joiners never munmap a stack still in use.
  • Live spawn requires Linux aarch64 (same as the trap backend).

Structs§

GuestThreadStart
Arguments for a newly created guest worker.

Functions§

alloc_tid
Allocates a new guest thread id (unique within the process run).
live_workers
Number of live worker threads spawned via bsdthread_create.
reset_thread_runtime
Resets thread counters for a new guest run.
spawn_guest_thread
Spawns a host thread that enters guest code at start.entry.
thread_selfid
Current host thread’s guest tid (stable for the host thread lifetime).