From owner-freebsd-bugs Fri Oct 30 04:40:05 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id EAA01046 for freebsd-bugs-outgoing; Fri, 30 Oct 1998 04:40:05 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id EAA00973 for ; Fri, 30 Oct 1998 04:40:00 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id EAA03130; Fri, 30 Oct 1998 04:40:01 -0800 (PST) Received: (from nobody@localhost) by hub.freebsd.org (8.8.8/8.8.8) id EAA00786; Fri, 30 Oct 1998 04:37:41 -0800 (PST) (envelope-from nobody) Message-Id: <199810301237.EAA00786@hub.freebsd.org> Date: Fri, 30 Oct 1998 04:37:41 -0800 (PST) From: info@highwind.com To: freebsd-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: www-1.0 Subject: kern/8500: FreeBSD 3.0 thread scheduler is broken Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 8500 >Category: kern >Synopsis: FreeBSD 3.0 thread scheduler is broken >Confidential: no >Severity: serious >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Oct 30 04:40:00 PST 1998 >Last-Modified: >Originator: Robert Fleischman >Organization: HighWind Software, Inc. >Release: 3.0 >Environment: FreeBSD zonda.highwind.com 3.0-19980831-SNAP FreeBSD 3.0-19980831-SNAP #0: Mon Aug 31 14:03:19 GMT 1998 root@make.ican.net:/usr/src/sys/compile/GENERIC i386 >Description: When an application has threads that are I/O intensive, that thread unfairly steals cycles from all other threads. This makes writing an MT program that does any real amount of I/O impossible. >How-To-Repeat: Just run this test program: /***************************************************************************** File: schedBug.C Contents: FreeBSD Scheduling Bug Illustrator Created: 28-Oct-1998 This program SHOULD print "Marking Time : 1", etc. However, the thread scheduler appears to NOT schedule the markTimeThread because the ioThread is so busy. If you uncomment the "::pthread_yield()" it works a little better. Ideally, you should get a print every second. g++ -o schedBug -D_REENTRANT -D_THREAD_SAFE -g -Wall schedBug.C -pthread *****************************************************************************/ #include #include #include #include #include #include #ifdef linux #include #endif #include unsigned int LENGTH = 1024 * 1024; void *ioThread(void *) { char *data = new char[LENGTH]; ::memset(data, 0, LENGTH); while (true) { int file = ::open("scrap", O_CREAT | O_TRUNC | O_WRONLY, 0666); assert(file != -1); assert(::write(file, data, LENGTH) == static_cast(LENGTH)); // ::pthread_yield(); assert(!::close(file)); } } void *markTimeThread(void *) { time_t start = ::time(0); while (true) { timeval timeout; timeout.tv_sec = 1; timeout.tv_usec = 0; ::select(0, 0, 0, 0, &timeout); ::printf("Marking Time: %lu\n", ::time(0) - start); } } int main(int, char **) { // Set up Thread Arguments pthread_t tid; pthread_attr_t attr; assert(!::pthread_attr_init(&attr)); assert(!::pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)); // Spawn markTimeThread assert(!::pthread_create(&tid, &attr, markTimeThread, 0)); // Spawn ioThread assert(!::pthread_create(&tid, &attr, ioThread, 0)); // main() goes away for a long time timeval timeout; timeout.tv_sec = 3600; timeout.tv_usec = 0; ::select(0, 0, 0, 0, &timeout); return EXIT_SUCCESS; } >Fix: I do not know a fix. However, the problem appears to be related to the use of the VTALARM timer only measuring USER space time and not kernel space time. >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message