English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] How to create an idle thread...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-12-09 (09:15)
From: Jonathan Roewen <jonathan.roewen@g...>
Subject: [Caml-list] How to create an idle thread...

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... */
    /* process any pending events, since nothing else to do :P */
    /* 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?