Re: Line-oriented blocking input from sockets?

2003-07-16 Thread Matthew Mondor
On Fri, Jul 11, 2003 at 03:04:18PM -0700, Damon Hastings wrote: This is probably a stupid question, but how do you do line-oriented blocking socket reads in Pth? There's a pth_read() which I assume blocks until a specified number of bytes (or eof) are received -- but I'm looking for

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

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

RE: Line-oriented blocking input from sockets?

2003-07-14 Thread David Schwartz
If the context-switching overhead turns out to be too high, then I will do exactly that. But it will mean maintaining state for each connection, and that state will only grow more complex with future enhancements by myself and others. Umm, huh?! If you don't maintain state for each

Re: Line-oriented blocking input from sockets?

2003-07-14 Thread Ralf S. Engelschall
On Sun, Jul 13, 2003, Damon Hastings wrote: [...] So it copies the old stack out and the new stack in during every context switch? I don't know much about thread implementation, but I guess I thought you could just swap out the stack pointer instead of copying the whole stack. [...] Sure,

Re: Line-oriented blocking input from sockets?

2003-07-14 Thread Ralf S. Engelschall
On Sun, Jul 13, 2003, Damon Hastings wrote: [...] See the file test_common.c in the Pth source tree. It provides a pth_readline() function (just a small but sufficient buffered wrapper around pth_read()) which should do exactly what you want. It looks like pth_readline_ev() reads a fixed

Re: Line-oriented blocking input from sockets?

2003-07-14 Thread Damon Hastings
--- Ralf S. Engelschall [EMAIL PROTECTED] wrote: On Sun, Jul 13, 2003, Damon Hastings wrote: [...] See the file test_common.c in the Pth source tree. It provides a pth_readline() function (just a small but sufficient buffered wrapper around pth_read()) which should do exactly what

RE: Line-oriented blocking input from sockets?

2003-07-14 Thread David Schwartz
Ah, well, I meant that a state machine must store state explicitly, whereas with threaded code the state is implied in the code flow (in effect, the thread system itself is a state machine.) If each thread executes a simple function like void foo() {A; B; C;}, then the equivalent state

RE: Line-oriented blocking input from sockets?

2003-07-14 Thread Damon Hastings
--- David Schwartz [EMAIL PROTECTED] wrote: Ah, well, I meant that a state machine must store state explicitly, whereas with threaded code the state is implied in the code flow (in effect, the thread system itself is a state machine.) If each thread executes a simple function like

Re: Line-oriented blocking input from sockets?

2003-07-13 Thread Ralf S. Engelschall
On Fri, Jul 11, 2003, Damon Hastings wrote: This is probably a stupid question, but how do you do line-oriented blocking socket reads in Pth? There's a pth_read() which I assume blocks until a specified number of bytes (or eof) are received -- but I'm looking for something like pth_gets() to

Re: Line-oriented blocking input from sockets?

2003-07-13 Thread Damon Hastings
--- Ralf S. Engelschall [EMAIL PROTECTED] wrote: On Fri, Jul 11, 2003, Damon Hastings wrote: This is probably a stupid question, but how do you do line-oriented blocking socket reads in Pth? There's a pth_read() which I assume blocks until a specified number of bytes (or eof) are

Re: Line-oriented blocking input from sockets?

2003-07-13 Thread Jason Evans
On Sun, Jul 13, 2003 at 05:41:14PM -0700, Damon Hastings wrote: If the context-switching overhead turns out to be too high, then I will do exactly that. But it will mean maintaining state for each connection, and that state will only grow more complex with future enhancements by myself and