Re: Line-oriented blocking input from sockets?

2003-07-15 Thread Ralf S. Engelschall
On Mon, Jul 14, 2003, Damon Hastings wrote:

 Can you give me a ballpark idea of the cost per
 context switch for 150 threads, almost all of which are waiting on I/O at
 any given time?

The costs depend on the particular method Pth uses for the context
implementation, of course. But all available methods Pth uses are very
cheap, because they are user-space only methods. Keep also in mind that
because Pth is a non-preemtive threading implementation, the context
switching is only performed if really required by the I/O.

 And does Pth block the entire process when all its threads
 are blocked?  (I would assume so, if you're using a global select under
 the covers.)

Sure, if _all_ threads are waiting for an event, the whole process is
waiting. And yes, internally the whole event management is based on a
single select(2) call.
   Ralf S. Engelschall
   [EMAIL PROTECTED]
   www.engelschall.com

__
GNU Portable Threads (Pth)http://www.gnu.org/software/pth/
Development Site  http://www.ossp.org/pkg/lib/pth/
Distribution Files  ftp://ftp.gnu.org/gnu/pth/
Distribution Snapshots ftp://ftp.ossp.org/pkg/lib/pth/
User Support Mailing List[EMAIL PROTECTED]
Automated List Manager (Majordomo)   [EMAIL PROTECTED]


RE: Line-oriented blocking input from sockets?

2003-07-15 Thread David Schwartz

  The costs depend on the particular method Pth uses for the context
  implementation, of course. But all available methods Pth uses are very
  cheap, because they are user-space only methods. Keep also in mind that
  because Pth is a non-preemtive threading implementation, the context
  switching is only performed if really required by the I/O.

   There is no reason a user-space context switch should be
 any faster than a
 kernel-space context switch unless the user-space context switch saves a
 kernel call. Measurements under Linux (at least) bear this out.

[snip]

I should point out that you didn't actually say that user-space context
switches are always faster than kernel context switches (which is false).
What you did say is that user-space only context swithces are generally
quite fast (which is true).

So I'm not dsiagreeing with you. I'm just pointing out that there's usally
kernel overhead associated with these user-space context switches,
especially if they're associated with I/O blocking.

DS


__
GNU Portable Threads (Pth)http://www.gnu.org/software/pth/
Development Site  http://www.ossp.org/pkg/lib/pth/
Distribution Files  ftp://ftp.gnu.org/gnu/pth/
Distribution Snapshots ftp://ftp.ossp.org/pkg/lib/pth/
User Support Mailing List[EMAIL PROTECTED]
Automated List Manager (Majordomo)   [EMAIL PROTECTED]