caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] How to create an idle thread...
@ 2005-12-09  9:15 Jonathan Roewen
  0 siblings, 0 replies; only message in thread
From: Jonathan Roewen @ 2005-12-09  9:15 UTC (permalink / raw)
  To: caml-list

Hi,

I'm having some trouble with the bytecode interpreter, and doing a
proper idle thread for my operating system.

The problem is, if there is no thread to run, the CPU should halt --
asm("hlt") -- and then, when an interrupt fires, this instruction
'returns', letting execution continue on.

However, my problem is that I don't know how to make it idle.

This is the code I have at present (vmthreads/scheduler.c:schedule_thread()):

if (run_thread == NULL) {
    /* then idle... */
    asm("hlt");
    /* process any pending events, since nothing else to do :P */
    caml_process_event();
    /* look for a waiting thread now that an interrupt has fired */
    goto try_again;
}

Interrupts are handled through the signals interface in byterun
(replacing signals).

For some reason, either the interrupt doesn't get processed, or
something else more obscure is happening. What my interrupt handler
does is use the signal interface to call into ocaml land when
appropriate, and run a small bit of ocaml code (wakes up a waiting
thread if there is one waiting for that irq) and return.

Anyone able to shed some light on why this isn't working?

Jonathan


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-12-09  9:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-09  9:15 [Caml-list] How to create an idle thread Jonathan Roewen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).