From owner-freebsd-current@FreeBSD.ORG Fri Oct 27 09:50:36 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 4BEC016A49E for ; Fri, 27 Oct 2006 09:50:36 +0000 (UTC) (envelope-from ru@rambler-co.ru) Received: from relay0.rambler.ru (relay0.rambler.ru [81.19.66.187]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7C5EF43DD5 for ; Fri, 27 Oct 2006 09:49:32 +0000 (GMT) (envelope-from ru@rambler-co.ru) Received: from relay0.rambler.ru (localhost [127.0.0.1]) by relay0.rambler.ru (Postfix) with ESMTP id E84856169; Fri, 27 Oct 2006 13:49:20 +0400 (MSD) Received: from edoofus.park.rambler.ru (unknown [81.19.65.108]) by relay0.rambler.ru (Postfix) with ESMTP id BC0E760EC; Fri, 27 Oct 2006 13:49:20 +0400 (MSD) Received: (from ru@localhost) by edoofus.park.rambler.ru (8.13.8/8.13.8) id k9R9nMlM007858; Fri, 27 Oct 2006 13:49:22 +0400 (MSD) (envelope-from ru) Date: Fri, 27 Oct 2006 13:49:22 +0400 From: Ruslan Ermilov To: Ivan Voras Message-ID: <20061027094922.GC6613@rambler-co.ru> References: <917908193.20061027102647@serebryakov.spb.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="GZVR6ND4mMseVXL/" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: No virus found Cc: freebsd-current@FreeBSD.org 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 09:50:36 -0000 --GZVR6ND4mMseVXL/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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=20 > > multithreading. They use KSE in different ways: libpthread uses N:M= =20 > > model and libthr uses 1:1 model, but bot use KSE to work. > > How will be possible to use these libraries (read: multithreaded=20 > > programs) when KSE will be optional, on kernel without KSE?! >=20 > Yes, isn't KSE by definition "that thing that is scheduled in the kernel"? >=20 KSE =3D=3D 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. : /* : * Initialize global thread allocation resources. : */ : void : threadinit(void) : { :=20 : mtx_init(&tid_lock, "TID lock", NULL, MTX_DEF); : tid_unrhdr =3D new_unrhdr(PID_MAX + 1, INT_MAX, &tid_lock); :=20 : thread_zone =3D uma_zcreate("THREAD", sched_sizeof_thread(), : thread_ctor, thread_dtor, thread_init, thread_fini, : UMA_ALIGN_CACHE, 0); : #ifdef KSE : ksegrp_zone =3D 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 : } Cheers, --=20 Ruslan Ermilov ru@FreeBSD.org FreeBSD committer --GZVR6ND4mMseVXL/ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQFFQdYiqRfpzJluFF4RApfUAJ9Q/CXmYqRCBcZ/uhZsn3a0BOMEuwCgjSwZ 8wMPpRfHKZOwXwYdtQrIv+w= =18KX -----END PGP SIGNATURE----- --GZVR6ND4mMseVXL/--