From owner-freebsd-bugs Thu Apr 30 10:20:04 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA12287 for freebsd-bugs-outgoing; Thu, 30 Apr 1998 10:20:04 -0700 (PDT) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: (from gnats@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA12252; Thu, 30 Apr 1998 10:20:02 -0700 (PDT) (envelope-from gnats) Received: from zwei.siemens.at (zwei.siemens.at [193.81.246.12]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA12131 for ; Thu, 30 Apr 1998 10:18:55 -0700 (PDT) (envelope-from lada@pc8811.gud.siemens.at) Received: from pc8811.gud.siemens.at (root@firix [10.1.143.100]) by zwei.siemens.at with ESMTP id TAA10878 for ; Thu, 30 Apr 1998 19:18:22 +0200 (MET DST) Received: (from lada@localhost) by pc8811.gud.siemens.at (8.8.8/8.8.8) id TAA29819; Thu, 30 Apr 1998 19:19:36 +0200 (CEST) (envelope-from lada) Message-Id: <199804301719.TAA29819@pc8811.gud.siemens.at> Date: Thu, 30 Apr 1998 19:19:36 +0200 (CEST) From: lada@pc8811.gud.siemens.at Reply-To: lada@pc8811.gud.siemens.at To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: bin/6467: Thread incremental priority update Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 6467 >Category: bin >Synopsis: Thread incremental priority update >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Apr 30 10:20:01 PDT 1998 >Last-Modified: >Originator: lada@pc8811.gud.siemens.at >Organization: >Release: FreeBSD 2.2.6-RELEASE i386 >Environment: >Description: The code in question increased the priority of runnable thread only if it became inactive after the last priority update. This means that the priority boost was added at most once to any inactive thread. >How-To-Repeat: the test program (test.c) follows; it was compiled with cc test.c -o test -lc_r #define _THREAD_SAFE #define DO_YIELD #define DO_YIELD2 #include #include #include void *writer( void *arg ) { int i = 0; int j; for (;; i++) switch (i%7) { case 0: puts( "One" ); break; case 1: puts( "Two" ); break; case 2: for (j=0; j<10000000;) j++; puts( "Three" ); break; case 3: puts( "Four" ); break; case 4: puts( "Five" ); break; case 5: puts( "Six" ); break; case 6: puts( "Seven" ); #ifdef DO_YIELD pthread_yield(); puts( "Yield in writer returned" ); #endif break; } return NULL; } void *looper( void *arg ) { long int i = 0; for (;;) { if (i==10000000) { puts( "Yielding" ); #ifdef DO_YIELD2 pthread_yield(); #endif puts( "Yield returned" ); i = 0; } else i++; } return NULL; } int main (void) { pthread_t printer, cpu_hog; void *result; pthread_create( &printer, pthread_attr_default, writer, "first" ); pthread_create( &cpu_hog, pthread_attr_default, looper, "second" ); pthread_join( printer, &result ); return 0; } >Fix: This patch seems to fix this (i.e. both threads get to run), but there are still some other problems: if DO_YIELD's are not defined only one of the threads seems to be running. This will require further investigation. --- uthread_kern.c 1998/04/30 16:31:53 1.1 +++ uthread_kern.c 1998/04/30 16:34:33 @@ -349,7 +349,7 @@ * the last incremental priority check was * made: */ - else if (timercmp(&_thread_run->last_inactive, &kern_inc_prio_time, >)) { + else if (timercmp(&_thread_run->last_inactive, &kern_inc_prio_time, <)) { /* * Increment the incremental priority * for this thread in the hope that >Audit-Trail: >Unformatted: Marino Ladavac To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message