From owner-freebsd-current@FreeBSD.ORG Fri Sep 28 19:07:14 2007 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 775BE16A417 for ; Fri, 28 Sep 2007 19:07:14 +0000 (UTC) (envelope-from sa2c@sa2c.net) Received: from el-out-1112.google.com (el-out-1112.google.com [209.85.162.183]) by mx1.freebsd.org (Postfix) with ESMTP id 3504613C481 for ; Fri, 28 Sep 2007 19:07:14 +0000 (UTC) (envelope-from sa2c@sa2c.net) Received: by el-out-1112.google.com with SMTP id r27so698291ele for ; Fri, 28 Sep 2007 12:07:13 -0700 (PDT) Received: by 10.114.154.1 with SMTP id b1mr1197398wae.1191004942378; Fri, 28 Sep 2007 11:42:22 -0700 (PDT) Received: from ?192.168.1.3? ( [220.102.212.119]) by mx.google.com with ESMTPS id j21sm6090260wah.2007.09.28.11.42.20 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 28 Sep 2007 11:42:21 -0700 (PDT) Message-ID: <46FD4B09.20006@sa2c.net> Date: Sat, 29 Sep 2007 03:42:17 +0900 From: NIIMI Satoshi MIME-Version: 1.0 To: freebsd-threads@freebsd.org Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit Cc: freebsd-current@freebsd.org Subject: sched_yield() is very slow when other threads are busy on FreeBSD-current X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Sep 2007 19:07:14 -0000 Hi, I experienced sched_yield() is very slow when other threads are busy on FreeBSD-current. When I run the program: ------------------------------------------------ #include #include #include #define NUM_THREAD (10) volatile int run = 0; void *start(void *p) { while (!run) ; return p; } int main() { pthread_t th[NUM_THREAD]; int i; for (i = 0; i < NUM_THREAD; i++) { assert(pthread_create(&th[i], NULL, start, NULL) == 0); sched_yield(); } run = 1; for (i = 0; i < NUM_THREAD; i++) assert(pthread_join(th[i], NULL) == 0); return 0; } ------------------------------------------------ The output of /usr/bin/time: FreeBSD 6.2-RELEASE, libthr, HZ=100, GENERIC kernel: 0.55 real 0.55 user 0.00 sys FreeBSD 7-CURRENT, libthr, HZ=100, kernel include GENERIC nooptions INVARIANTS, INVARIANT_SUPPORT, WITNESS, WITNESS_SKIPSPIN: 164.16 real 162.80 user 0.00 sys I tried SCHED_ULE too, but does not help so much. Increasing HZ helps to perform better, but still very slower than FreeBSD-6. Thanks, -- NIIMI Satoshi