From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST autolearn=disabled version=3.1.3 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id BB61CBC69 for ; Sun, 11 Nov 2007 21:38:30 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAPf2NkdQDPIalmdsb2JhbACBW40pAQEBAQcEBgcKEQc X-IronPort-AV: E=Sophos;i="4.21,402,1188770400"; d="scan'208";a="5679022" Received: from smtp20.orange.fr ([80.12.242.26]) by mail3-smtp-sop.national.inria.fr with ESMTP; 11 Nov 2007 21:38:31 +0100 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2002.orange.fr (SMTP Server) with ESMTP id 4E16F1C00350 for ; Sun, 11 Nov 2007 21:38:30 +0100 (CET) Received: from localhost.localdomain (Mix-Lyon-303-1-56.w193-248.abo.wanadoo.fr [193.248.43.56]) by mwinf2002.orange.fr (SMTP Server) with ESMTP id 397D31C000C2 for ; Sun, 11 Nov 2007 21:38:29 +0100 (CET) X-ME-UUID: 20071111203829235.397D31C000C2@mwinf2002.orange.fr Date: Sun, 11 Nov 2007 20:40:19 +0100 From: Fabrice Marchant To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Why 'Graphics.wait_next_event' doesn't reply anymore ? Message-ID: <20071111204019.4697d387@localhost.localdomain> In-Reply-To: <1194799714.473732620f33e@webmail.in-berlin.de> References: <20071110230145.3aebafe4@localhost.localdomain> <20071111150720.4f8d1c44@localhost.localdomain> <1194799714.473732620f33e@webmail.in-berlin.de> X-Mailer: Claws Mail 2.10.0 (GTK+ 2.10.13; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; bandel:01 in-berlin:01 scheduler:01 scheduler:01 printf:01 printf:01 stdout:01 stdout:01 uncomment:01 wrote:01 oliver:01 oliver:01 graph:01 caml-list:01 caml-list:01 Hi Oliver ! Thanks to have considered my problem. On Sun, 11 Nov 2007 17:48:34 +0100 Oliver Bandel wrote: > http://caml.inria.fr/pub/ml-archives/caml-list/2002/09/d29ca3379fe68e3cdbd36323f5f409c0.en.html > This code looks ugly. ... > It forces calls to the scheduler all too often. > And it does it at three places. And in the print-loop > it clals it every time! > This is the way of wasting ressources. I think these 'yields' are only desperate attempts to hint the scheduler to do its job - that it doesn't as we could expected -. > open Thread > open Graphics > > > let code1 () = > let x = ref 0 in > while true do > incr x; > Printf.printf "alpha %d\n" !x; > flush stdout (* ; display_mode false; fill_circle 100 100 20; synchronize ()*) > done > > let code2 () = > open_graph " 300x300"; > while true do > let st = wait_next_event [Key_pressed] in > Printf.printf "key %c pressed...\n" st.key; > flush stdout > done > > let _ = > ignore(Thread.create code1()); > code2() Yes, it perfectly works. So I compared it with my hanging example to try to understood what was responsible for blocking. If you uncomment the lines I inserted in code1, things begins to go more or less wrong. On my computer, from time to time, when you alternatively focus console output and graphical window, some characters can be suddenly spat. Or keyboard input is completely ignored... Thanks to have make things progress ! I think we aren't far to understand. Regards, Fabrice