Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Oct 2006 13:49:22 +0400
From:      Ruslan Ermilov <ru@FreeBSD.org>
To:        Ivan Voras <ivoras@fer.hr>
Cc:        freebsd-current@FreeBSD.org
Subject:   Re: KSE, libpthread & libthr: almost newbie question
Message-ID:  <20061027094922.GC6613@rambler-co.ru>
In-Reply-To: <ehshjl$dsp$1@sea.gmane.org>
References:  <917908193.20061027102647@serebryakov.spb.ru> <ehshjl$dsp$1@sea.gmane.org>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
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.

: /*
:  * 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
: }


Cheers,
-- 
Ruslan Ermilov
ru@FreeBSD.org
FreeBSD committer

[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (FreeBSD)

iD8DBQFFQdYiqRfpzJluFF4RApfUAJ9Q/CXmYqRCBcZ/uhZsn3a0BOMEuwCgjSwZ
8wMPpRfHKZOwXwYdtQrIv+w=
=18KX
-----END PGP SIGNATURE-----
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20061027094922.GC6613>