From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA01838; Wed, 16 Jul 2003 14:00:36 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA07425 for ; Wed, 16 Jul 2003 14:00:35 +0200 (MET DST) Received: from acsn03.bu.edu (acsn03.bu.edu [128.197.159.63]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h6GC0YT07288; Wed, 16 Jul 2003 14:00:34 +0200 (MET DST) Received: from bu.edu (bays193-0b01-dhcp060.bu.edu [168.122.153.60]) by acsn03.bu.edu ((8.9.3p2.buoit.v1.3)/BU_Server-1.3) with ESMTP id HAA157186; Wed, 16 Jul 2003 07:59:37 -0400 Date: Wed, 16 Jul 2003 07:59:31 -0400 Subject: Re: [Caml-list] PortAudio on ocaml Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) Cc: caml-list@inria.fr, Likai Liu To: Xavier Leroy From: Likai Liu In-Reply-To: <20030716115544.A29200@pauillac.inria.fr> Message-Id: Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.552) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; liu:99 caml-list:01 crux:01 callback:01 allocating:01 printf:01 crunch:01 thrashing:01 stringent:99 unspecified:01 dispatching:01 runtime:01 callbacks:01 threads:01 invoke:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wednesday, July 16, 2003, at 05:55 AM, Xavier Leroy wrote: > That's the crux of the problem, indeed. I looked at the PortAudio > tutorial and found this little gem: > > Your callback function is often called by an interrupt, or low level > process so you should not do any complex system activities like > allocating memory, or reading or writing files, or printf(). Just > crunch numbers and generate audio signals. I'm giving a bit leeway on the activities that allocate memory, since most of the time it's just manipulation of some data structure in memory. Granted, it might cause hard-disk activity every once in a while for thrashing, but even simple memory access could cause this too. Also, note that the restriction is tight on some platforms but not so tight on others. I was hoping at least this would work on these not so stringent systems. However, I think invoking system calls that block the callback for possibly unspecified amount of time is the forbidden game. I think garbage collection inside the callback is probably okay, if it doesn't do other fancy things, such as dispatching signals or influence thread scheduling. What does O'Caml runtime do during garbage collection? > - Event loops (register Caml callbacks, then enter a library-provider > event > handler that will block and invoke the callbacks one at a time, > but not from a signal or interrupt context). That's also a possibility; does it play well with O'Caml Threads? Thanks for the response. liulk ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners