From owner-freebsd-threads@FreeBSD.ORG Mon Feb 2 14:10:48 2004 Return-Path: Delivered-To: freebsd-threads@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DC54C16A4CF for ; Mon, 2 Feb 2004 14:10:48 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id CB81E43D31 for ; Mon, 2 Feb 2004 14:10:20 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i12MAJFR057871 for ; Mon, 2 Feb 2004 14:10:19 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i12MAJx4057870; Mon, 2 Feb 2004 14:10:19 -0800 (PST) (envelope-from gnats) Date: Mon, 2 Feb 2004 14:10:19 -0800 (PST) Message-Id: <200402022210.i12MAJx4057870@freefall.freebsd.org> To: freebsd-threads@FreeBSD.org From: Craig Rodrigues Subject: Re: kern/43887: abnormal CPU useage when use pthread_mutex X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Craig Rodrigues List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Feb 2004 22:10:49 -0000 The following reply was made to PR kern/43887; it has been noted by GNATS. From: Craig Rodrigues To: freebsd-gnats-submit@freebsd.org Cc: t_fisher@163.com Subject: Re: kern/43887: abnormal CPU useage when use pthread_mutex Date: Mon, 2 Feb 2004 17:05:28 -0500 Hi, I don't think that this PR is very meaningful, and should be closed. This PR basically complains about the following code consuming too much CPU if you take out the usleep(). ===================================================================== #include #include #include int main(int argc,char** argv) { pthread_mutex_t mutex; long i,j; j =0; pthread_mutex_init(&mutex,NULL); while(1) { pthread_mutex_lock(&mutex); i = j*j; j++; pthread_mutex_unlock(&mutex); printf("i=%ld\n",i); if(usleep(800)== -1) printf("usleep fail. %s",strerror(errno)); } return 0; } ===================================================================== Well, this code isn't doing too much, except for spinning in a tight loop. I think this PR should be closed. -- Craig Rodrigues rodrigc@crodrigues.org