From owner-freebsd-threads@FreeBSD.ORG Tue Jun 24 07:12:47 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 9FD8B106568D for ; Tue, 24 Jun 2008 07:12:47 +0000 (UTC) (envelope-from saikothapalli@gmail.com) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.237]) by mx1.freebsd.org (Postfix) with ESMTP id 6D8CF8FC1C for ; Tue, 24 Jun 2008 07:12:47 +0000 (UTC) (envelope-from saikothapalli@gmail.com) Received: by rv-out-0506.google.com with SMTP id b25so9931782rvf.43 for ; Tue, 24 Jun 2008 00:12:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=Ko0n1v8SCCEpLE0bJaTH/+BqrhgMgNtYD1qFIvOjONU=; b=wHAjL+DIMTrQYTs1fEsYd20vTx/d25wtyT4z3iQm5v3kvf+uXrZkPReR68b/hgAYlU XHX570Z+6rVItn9Oh2jAWSAR4JGLkL8vzKsZQ1nubm3cXCRcFKKH2pBOngkakdpve2T/ 3LZZKBX9UmbfONMOHHJVPkpV6Mt8VjCQ6DH/E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=N4J08Cg8s0tKwzo4futYZ4gW3Szusp9RLIEth99kY8XaCXeO706RfNiJabdRHaHIQC cxHLF0dK+39KK6z+vNxNw/LG/eKdwmhHBuM/QMOOrJCkJYPaToAvi6O88/eLQDIZV/k2 B3aApKb13/TMsSubC+MXWXnZMICgP2HcWj70Q= Received: by 10.141.176.4 with SMTP id d4mr14246304rvp.14.1214289866338; Mon, 23 Jun 2008 23:44:26 -0700 (PDT) Received: by 10.115.108.14 with HTTP; Mon, 23 Jun 2008 23:44:26 -0700 (PDT) Message-ID: <52db57fb0806232344y95eb159ra2dd43a4462ee082@mail.gmail.com> Date: Tue, 24 Jun 2008 12:14:26 +0530 From: "Saradhi Kothapalli" To: freebsd-threads@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: 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:12:47 -0000 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. 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