Re: Feature request: ability to use libeio with multiple event loops

2011-12-21 Thread Hongli Lai
On Thu, Dec 22, 2011 at 3:02 AM, Marc Lehmann wrote: > With threads, you can avoid swapping some registers, most notably the MMU > registers, which are often very costly to swap, to the extent that a number > of cpus even have extra support for multiple "contexts". > >> Are you talking about hardw

Re: Is that ev_run()/ev_loop() inhibited in multiple thread of current libev?

2011-12-21 Thread freebsdj
Many thanks! Sorry for the format, I didn't wrap the long line. Actually, the thing confused me is that: NDEBUG is usually allowed when compiling production code, so I suspected that whether it's feasible to embedded code in assert(). Additionally, ev_run() is a blocking function, how to protec

Re: Feature request: ability to use libeio with multiple event loops

2011-12-21 Thread Marc Lehmann
On Wed, Dec 21, 2011 at 09:38:01PM +0100, Hongli Lai wrote: > > Well, threads were originally invented because single cpus only had a single > > set of registers, and swapping these can be costly (especially with vm > > state). > > I agree with your assertion that single CPUs had a single set of

Re: Feature request: ability to use libeio with multiple event loops

2011-12-21 Thread Marc Lehmann
On Wed, Dec 21, 2011 at 09:21:15PM +0100, Hongli Lai wrote: > I know that it's *possible* to make it work with the way libeio is > right now. What I'm concerned about is that it takes me a huge amount > of boilerplate code to do so. Consider all these steps: I am concerned that adding another lay

Re: Feature request: ability to use libeio with multiple event loops

2011-12-21 Thread Marc Lehmann
On Wed, Dec 21, 2011 at 11:43:54PM +0100, Ben Noordhuis wrote: > > A tasks witch will typically only change the registers it needs to > > switch. For example, both MMU and FPU registers are only changed on demand > > on Linux, on architectures that allow that. > > That's better. Your original st

Re: Feature request: ability to use libeio with multiple event loops

2011-12-21 Thread Ben Noordhuis
On Wed, Dec 21, 2011 at 20:54, Marc Lehmann wrote: > Registers don't need magic to stay "intact" (== have the same value), they > basically never change on their own, instructions must change them. There > are exceptions, but the point is true even then: registers don't change > due to magic, they

Re: Feature request: ability to use libeio with multiple event loops

2011-12-21 Thread Hongli Lai
On Wed, Dec 21, 2011 at 1:46 AM, Marc Lehmann wrote: > Well, threads were originally invented because single cpus only had a single > set of registers, and swapping these can be costly (especially with vm > state). I agree with your assertion that single CPUs had a single set of registers and tha

Re: Feature request: ability to use libeio with multiple event loops

2011-12-21 Thread Hongli Lai
On Wed, Dec 21, 2011 at 1:12 AM, Marc Lehmann wrote: > libeio actually makes no assumptions about the existance of an event loop, > or there being only one. > ... > well, I pointed out a way to you how to work with multiple event loops, so > I am not sure why you write that: it is not true. > ...

Re: Feature request: ability to use libeio with multiple event loops

2011-12-21 Thread Marc Lehmann
On Wed, Dec 21, 2011 at 02:43:14PM +0100, Ben Noordhuis wrote: > > Maybe you have simply the wrong idea about what a context switch is or how > > a cpu or mmu works. > > Well put in a nicely condescending tone. Maybe a less arrogant mail might have gotten a more favourable response? Just sayin.

Re: Is that ev_run()/ev_loop() inhibited in multiple thread of current libev?

2011-12-21 Thread Marc Lehmann
On Thu, Dec 22, 2011 at 01:58:52AM +0800, freebsdj wrote: > My project is a networking server, I have an assign thread to accept > connections and > dispatch fd to query threads, both assign thread and query threads are > using ev_run() First, can you properly format your e-mail? It's really anno

Is that ev_run()/ev_loop() inhibited in multiple thread of current libev?

2011-12-21 Thread freebsdj
I apologise if this question's been asked before -- I've searched around, but found nothing. I use libev to notify IO event in my project. My project is a networking server, I have an assign thread to accept connections and dispatch fd to query threads, both assign thread and query threads are us

Re: Feature request: ability to use libeio with multiple event loops

2011-12-21 Thread Ben Noordhuis
On Wed, Dec 21, 2011 at 04:19, Marc Lehmann wrote: > On Wed, Dec 21, 2011 at 03:37:48AM +0100, Ben Noordhuis > wrote: >> You either have an overly broad definition of or simply the wrong idea >> about what CPU registers are. > > Then you can surely point out where my idea differs from, say, inte