From owner-freebsd-current@FreeBSD.ORG Fri Oct 27 19:34:27 2006 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0ED7616A40F; Fri, 27 Oct 2006 19:34:27 +0000 (UTC) (envelope-from prvs=julian=44840db18@elischer.org) Received: from a50.ironport.com (a50.ironport.com [63.251.108.112]) by mx1.FreeBSD.org (Postfix) with ESMTP id C8C8143D49; Fri, 27 Oct 2006 19:34:26 +0000 (GMT) (envelope-from prvs=julian=44840db18@elischer.org) Received: from unknown (HELO [10.251.18.229]) ([10.251.18.229]) by a50.ironport.com with ESMTP; 27 Oct 2006 12:34:26 -0700 Message-ID: <45425F42.1070909@elischer.org> Date: Fri, 27 Oct 2006 12:34:26 -0700 From: Julian Elischer User-Agent: Thunderbird 1.5.0.7 (Macintosh/20060909) MIME-Version: 1.0 To: Ruslan Ermilov References: <917908193.20061027102647@serebryakov.spb.ru> <20061027094922.GC6613@rambler-co.ru> In-Reply-To: <20061027094922.GC6613@rambler-co.ru> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-current@freebsd.org, Ivan Voras Subject: Re: KSE, libpthread & libthr: almost newbie question X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Oct 2006 19:34:27 -0000 Ruslan Ermilov wrote: > On Fri, Oct 27, 2006 at 10:56:21AM +0200, Ivan Voras wrote: >> Lev Serebryakov wrote: >>> Hello , >>> >>> I've was sure, that both libpthread and libthr use KSE to make >>> multithreading. They use KSE in different ways: libpthread uses N:M >>> model and libthr uses 1:1 model, but bot use KSE to work. >>> How will be possible to use these libraries (read: multithreaded >>> programs) when KSE will be optional, on kernel without KSE?! >> Yes, isn't KSE by definition "that thing that is scheduled in the kernel"? >> > KSE == N:M threading > > A 1:1 threading (libthr) is much simpler than N:M threading (libpthread), > and thus doesn't require KSE support in the kernel; see kse(2) manpage > for details. Without the KSE option in the kernel, all kse(2) syscalls > will return EOPNOTSUPP, and a lot of code becomes redundant. KSE is a misnomer that I abandoned long ago.. mostly it is the thread fairness code that is independent of what threading library is running (see the other email I just sent) (or should be) > > : /* > : * Initialize global thread allocation resources. > : */ > : void > : threadinit(void) > : { > : > : mtx_init(&tid_lock, "TID lock", NULL, MTX_DEF); > : tid_unrhdr = new_unrhdr(PID_MAX + 1, INT_MAX, &tid_lock); > : > : thread_zone = uma_zcreate("THREAD", sched_sizeof_thread(), > : thread_ctor, thread_dtor, thread_init, thread_fini, > : UMA_ALIGN_CACHE, 0); > : #ifdef KSE > : ksegrp_zone = uma_zcreate("KSEGRP", sched_sizeof_ksegrp(), > : ksegrp_ctor, NULL, NULL, NULL, > : UMA_ALIGN_CACHE, 0); > : kseinit(); /* set up kse specific stuff e.g. upcall zone*/ > : #endif The KSEGRP is a part of the fairness code in general and independent of M:N and 1:1 > : } > > > Cheers,