From owner-freebsd-threads@FreeBSD.ORG Tue Jun 24 07:37:51 2008 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 04FDA1065776 for ; Tue, 24 Jun 2008 07:37:51 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outQ.internet-mail-service.net (outq.internet-mail-service.net [216.240.47.240]) by mx1.freebsd.org (Postfix) with ESMTP id DA4A28FC17 for ; Tue, 24 Jun 2008 07:37:50 +0000 (UTC) (envelope-from julian@elischer.org) Received: from idiom.com (mx0.idiom.com [216.240.32.160]) by out.internet-mail-service.net (Postfix) with ESMTP id 9B9252433; Tue, 24 Jun 2008 00:23:22 -0700 (PDT) Received: from julian-mac.elischer.org (localhost [127.0.0.1]) by idiom.com (Postfix) with ESMTP id F18CD2D6004; Tue, 24 Jun 2008 00:23:20 -0700 (PDT) Message-ID: <4860A0F4.1040304@elischer.org> Date: Tue, 24 Jun 2008 00:23:32 -0700 From: Julian Elischer User-Agent: Thunderbird 2.0.0.14 (Macintosh/20080421) MIME-Version: 1.0 To: Saradhi Kothapalli References: <52db57fb0806232344y95eb159ra2dd43a4462ee082@mail.gmail.com> In-Reply-To: <52db57fb0806232344y95eb159ra2dd43a4462ee082@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-threads@freebsd.org Subject: Re: Threads stuck in kserel state X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Jun 2008 07:37:51 -0000 Saradhi Kothapalli wrote: > Hi > > I am running FreeBSD 5.4 on my machine. When i run mpd on it, i see it stuck > in kserel state. > I have written a sample thread program to check whether its an mpd problem > or not. > > Observations on the Sample test program: > > I have created only one thread from the process, but the top output shows > total 3 entries. yes The thread you started in sleeping in ttyin. the thread library greated a background thread to handle signal delivery (ksesig). When the main thread did ttyin, it blocked, so a third thread was created to make sure that if any other work had to be done there was a thread to do it. that third thread is waiting for more work to appear, and in kserel (kse-release). > Even when the thread has finished i see 2 entries that to one in kserel and > other in ksesig state. > > Is the main process stuck in "kserel" state or is it an expected behavior? > Is it because of KSE the other thread is shown in top output? Is the state > "ksesig" signifies that it is waiting for an event to occur? > > > Thanks in advance for the help. > > Regards > Saradhi > > > The Sample Test program: > > #include > #include > #include > #include > #include > #include > #include > #include > #include > > pthread_mutex_t mutex; > > static void > startFn(void * arg) > { > printf("\n *** Thread Start Function *** \n"); > getchar(); > return; > } > > static void > endFn(void * arg, int done) > { > printf("\n *** Thread End Function *** \n"); > getchar(); > return; > } > > static void > thrStart() > { > struct paction * thr; > uint32_t temp; > > if ( paction_start(&thr, &mutex, startFn, endFn, &temp) == -1 ) > { > printf("\n *** Failed to start thread *** \n "); > getchar(); > } > return ; > } > > int main() > { > > int ret = pthread_mutex_init(&mutex, NULL); > if ( ret != 0 ) > { > printf("\n *** Mutex initialization Failed *** \n"); > return -1; > } > > printf("\n *** calling thread start *** \n "); > getchar(); > > thrStart(); > > for ( ; ; ) > { > sleep(1); > } > return 0; > } > > THE TOP OUTPUT WITH THREAD DISPLAY TURNED ON: > > When the thread is in existence (both during start and end function): > ----------------------------------------------------------------------------------------------------- > > 18387 root 20 0 3384K 1760K ksesig 0:00 0.00% 0.00% thrd > 18387 root 20 0 3384K 1760K kserel 0:00 0.00% 0.00% thrd > 18387 root 5 0 3384K 1760K ttyin 0:00 0.00% 0.00% thrd > > After the thread execution is completed (the for loop): > --------------------------------------------------------- > 18387 root 20 0 3384K 1752K ksesig 0:00 0.00% 0.00% thrd > 18387 root 20 0 3384K 1752K kserel 0:00 0.00% 0.00% thrd > _______________________________________________ > freebsd-threads@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-threads > To unsubscribe, send any mail to "freebsd-threads-unsubscribe@freebsd.org"