From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10800 invoked by alias); 22 Aug 2007 20:39:08 -0000 Received: (qmail 10673 invoked by uid 22791); 22 Aug 2007 20:39:07 -0000 X-Spam-Check-By: sourceware.org Received: from web32615.mail.mud.yahoo.com (HELO web32615.mail.mud.yahoo.com) (68.142.207.242) by sourceware.org (qpsmtpd/0.31) with SMTP; Wed, 22 Aug 2007 20:39:05 +0000 Received: (qmail 10860 invoked by uid 60001); 22 Aug 2007 20:39:04 -0000 X-YMail-OSG: 2qQ262UVM1lidEJMS_ep95znMGvICoXdQrVisMXK0FziaaNU5e._GpMcrUJsqIvke4X4K7AyirAPhqHOfcwk8iqniKBjNyKyvvr2a7Kkpjt1xlDyMeA- Received: from [200.196.192.43] by web32615.mail.mud.yahoo.com via HTTP; Wed, 22 Aug 2007 17:39:04 ART Date: Wed, 22 Aug 2007 23:17:00 -0000 From: Virgilio Alexandre Fornazin Subject: patch for sched_yield() To: pthreads-win32@sourceware.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <353903.10622.qm@web32615.mail.mud.yahoo.com> X-IsSubscribed: yes Mailing-List: contact pthreads-win32-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sourceware.org X-SW-Source: 2007/txt/msg00042.txt.bz2 Hi I did a change in sched_yield() to support multi-processor systems after checking the OS (NT style oses). I managed to compile it under VS2005 SP1. I'm putting the code here to share with pthreads project. I changed the implementation from: { Sleep (0); return 0; } To: { static OSVERSIONINFO vs = {0}; if (vs.dwOSVersionInfoSize == 0) { vs.dwOSVersionInfoSize = sizeof(vs); GetVersionEx(&vs); } if (vs.dwPlatformId == VER_PLATFORM_WIN32_NT) { SwitchToThread (); } else { Sleep (0); } return 0; } I saw in another mailing list that Sleep(0) sometimes doesn't yield the thread and performs nothing on some Windows versions. I hope this help somebody and could be integrated to main code after more testing with other cpu/configurations. Flickr agora em português. Você clica, todo mundo vê. http://www.flickr.com.br/