From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id CE9AFBB9C for ; Fri, 9 Dec 2005 10:15:06 +0100 (CET) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.196]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jB99F6VJ002818 for ; Fri, 9 Dec 2005 10:15:06 +0100 Received: by wproxy.gmail.com with SMTP id 36so1131554wra for ; Fri, 09 Dec 2005 01:15:05 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=BrXaFh9DMJjjzoswhUz4HexvISiyVTly1ykdsi5JE4KBzTDUnfBFu4J0ekPjhDgzi5kKD+YLMOVvWxKe2BW+KMbPRzl2f70aZbCLe5Be6VAuWIgv5KETDZIZukPs6ENQnDfru/oVo0cYuWehQjVZAVqepVo/BLN050MHGv/N6QE= Received: by 10.64.10.17 with SMTP id 17mr1340624qbj; Fri, 09 Dec 2005 01:15:05 -0800 (PST) Received: by 10.65.22.12 with HTTP; Fri, 9 Dec 2005 01:15:05 -0800 (PST) Message-ID: Date: Fri, 9 Dec 2005 22:15:05 +1300 From: Jonathan Roewen To: caml-list@yquem.inria.fr Subject: [Caml-list] How to create an idle thread... MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Miltered: at nez-perce with ID 43994B1A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 bytecode:01 scheduler:01 byterun:01 replacing:01 handler:01 ocaml:01 ocaml:01 hlt:98 hlt:98 interrupts:98 thread:02 thread:02 caml:02 asm:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_BY_IP autolearn=disabled version=3.0.3 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 =3D=3D 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