1. Non Blocking Support
- Posted by C Bouzy <CBouzy at Egisca.com> Feb 15, 2007
- 695 views
Hello All, I started working on Nexus Radio 2 and I just wanted to know if EU will have non blocking support in the near future, or is anyone working on this? "If you do what you have always done, you will get what you always got."
2. Re: Non Blocking Support
- Posted by Dan Moyer <danielmoyer at prodigy.net> Feb 15, 2007
- 633 views
C Bouzy wrote: > > Hello All, > > I started working on Nexus Radio 2 and I just wanted to know if EU > will have non blocking support in the near future, or is anyone working > on this? > > > "If you do what you have always done, you will get what you always got." Chris, Dunno about your question, but: at Egisca, in "History", error in the following: "Egisca is preparing to release a new class of applications that will surly impress consumers." Spell checkers can't catch words that are the wrong word spelled correctly! :) Dan Moyer (who may surely sometimes be surly & cross, but hopefully not too often!)
3. Re: Non Blocking Support
- Posted by Jonas Temple <jtemple at yhti.net> Feb 15, 2007
- 610 views
Chris, I'm currently using tdll by Daniel Kluss and found that it works quite well! I'm about to release a new version of FROG that uses Euphoria's new task routines and Daniel's tdll. Users will be able to run multiple SQL statements against a host at the same time. I did have to modify Win32Lib (if that's what you use) to put a call to task_yield() in the doEvents() routine. Jonas Temple http://www.innovativesys.net
4. Re: Non Blocking Support
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> Feb 15, 2007
- 621 views
Jonas Temple wrote: > > Chris, > > I'm currently using tdll by Daniel Kluss and found that it works quite well! > > I'm about to release a new version of FROG that uses Euphoria's new task > routines > and Daniel's tdll. Users will be able to run multiple SQL statements against > a host at the same time. > > I did have to modify Win32Lib (if that's what you use) to put a call to > task_yield() > in the doEvents() routine. > > Jonas Temple > <a href="http://www.innovativesys.net">http://www.innovativesys.net</a> Did you plainly insert a task_yield() call at line 33376 or is it anything subtler? CChris
5. Re: Non Blocking Support
- Posted by Jonas Temple <jtemple at yhti.net> Feb 15, 2007
- 616 views
CChris wrote: > > <a href="http://www.innovativesys.net">http://www.innovativesys.net</a> > > Did you plainly insert a task_yield() call at line 33376 or is it > anything subtler? > > CChris Actually, looking at what I did, I insert this into two places. And, of course, I can't remember why I did the first! :) The first is in eventLoop() procedure:
-- Gather some entropy for the random integer routine w32Seed = remainder((w32Seed * peek4u(msg+16)) + 1 + peek4u(msg+20) * peek4u(msg+24), #FFFFFFFF) w32Proc( xTranslateMessage, { msg } ) w32Proc( xDispatchMessage, { msg } ) task_yield()
The second is in doEvents():
global procedure doEvents(integer id) atom msg, hWnd if vWinMainState != kStarted then return end if if id = 0 then hWnd = 0 else if validId(id) = w32False then return end if hWnd = getHandle(id) end if -- Allocate a message buffer msg = w32acquire_mem(0, SIZEOF_MSG) if w32Func( xPeekMessage, { msg, hWnd, 0, 0, PM_REMOVE } ) then w32Proc( xTranslateMessage, { msg } ) w32Proc( xDispatchMessage, { msg } ) task_yield() end if w32release_mem(msg) end procedure
And to be honest, I haven't noticed any performance depreciation using task_yield() in these routines. Sorry I can't give you the exact line numbers, my copy of Win32lib has some "tweaks". Just in case you're curious, here's how I modified my code (which was not a lot!) * included tdll.e (of course) * changed my open_dll() call to open_tdll() * For functions that I wanted non-blocking, I replaced the define_c_func() calls with define_t_func() calls. In my case the only change was replacing the "c" in define_c_func with "t". The parameters to the define_t_func were identical to define_c_func. I then replaced the c_func() calls with t_func(). Again, the only change was the "c" to "t". I even left all the rest of the C functions with the standard define_c_func/c_func Euphoria routines and they worked fine! In my main program I coded a routine to kick off the task and then wait until it was complete:
task = task_create(routine_id("execute_task"), {invoked_from, ctl_index}) task_schedule(task,1) -- Process message loop until end of task while find(task, task_list()) do doEvents(0) task_yield() end while
Carefully placed task_yield() calls, both in the main program and in Win32Lib seemed to keep things in order. I did have to rework a HUGE portion of my code to eliminate my over-use of globals. But that was my issue, not tdll. I just had to ensure that one task would not interfere with the values in another task. I was having some problems at first before I figured out how to place calls to task_yield() and Daniel suggested his APC DLL which he said was better than TDLL but I could not figure out how to use the library and never got a response back from him on a request for documentation. I just found the TDLL calls easier to understand. HTH, Jonas Temple http://www.innovativesys.net
6. Re: Non Blocking Support
- Posted by C Bouzy <CBouzy at Egisca.com> Feb 15, 2007
- 617 views
Hello Dan, Thank you for catching that error. C. Bouzy "If you do what you have always done, you will get what you always got." Dan Moyer wrote: > Dunno about your question, but: > at Egisca, in "History", error in the following: > "Egisca is preparing to release a new class of applications that will surly > impress consumers." > > Spell checkers can't catch words that are the wrong word spelled >correctly!
7. Re: Non Blocking Support
- Posted by C Bouzy <CBouzy at Egisca.com> Feb 15, 2007
- 606 views
Hello Jonas, Thank you for your feedback. I will give your method a try and see if it works. C. Bouzy "If you do what you have always done, you will get what you always got."
8. Re: Non Blocking Support
- Posted by Robert Craig <rds at RapidEuphoria.com> Feb 15, 2007
- 614 views
C Bouzy wrote: > I started working on Nexus Radio 2 and I just wanted to know if EU > will have non blocking support in the near future, or is anyone working > on this? ... > Hello Jonas, > > Thank you for your feedback. I will give your method a try > and see if it works. I'm not working on non-blocking support currently, but I'm still interested in adding support in that area. I guess I'd like to see more people experiment with multitasking, before I get too far ahead of the community. Let us know how it goes. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
9. Re: Non Blocking Support
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> Feb 15, 2007
- 631 views
Jonas Temple wrote: > > CChris wrote: > > > <a href="http://www.innovativesys.net">http://www.innovativesys.net</a> > > > > Did you plainly insert a task_yield() call at line 33376 or is it > > anything subtler? > > > > CChris > > Actually, looking at what I did, I insert this into two places. And, of > course, > I can't remember why I did the first! :) > > The first is in eventLoop() procedure: > > }}} <eucode> > -- Gather some entropy for the random integer routine > w32Seed = remainder((w32Seed * peek4u(msg+16)) > + 1 + peek4u(msg+20) * peek4u(msg+24), > #FFFFFFFF) > > w32Proc( xTranslateMessage, { msg } ) > w32Proc( xDispatchMessage, { msg } ) > task_yield() > </eucode> {{{ > > The second is in doEvents(): > > }}} <eucode> > global procedure doEvents(integer id) > atom msg, hWnd > > if vWinMainState != kStarted then > return > end if > > if id = 0 then > hWnd = 0 > else > if validId(id) = w32False then > return > end if > hWnd = getHandle(id) > end if > > -- Allocate a message buffer > msg = w32acquire_mem(0, SIZEOF_MSG) > > if w32Func( xPeekMessage, { msg, hWnd, 0, 0, PM_REMOVE } ) then > w32Proc( xTranslateMessage, { msg } ) > w32Proc( xDispatchMessage, { msg } ) > task_yield() > end if > w32release_mem(msg) > > end procedure > </eucode> {{{ > > And to be honest, I haven't noticed any performance depreciation using > task_yield() > in these routines. > > Sorry I can't give you the exact line numbers, my copy of Win32lib has some > "tweaks". > > Just in case you're curious, here's how I modified my code (which was not a > lot!) > > * included tdll.e (of course) > * changed my open_dll() call to open_tdll() > * For functions that I wanted non-blocking, I replaced the define_c_func() > calls > with define_t_func() calls. In my case the only change was replacing the "c" > in define_c_func with "t". The parameters to the define_t_func were identical > to define_c_func. I then replaced the c_func() calls with t_func(). Again, > the only change was the "c" to "t". I even left all the rest of the C > functions > with the standard define_c_func/c_func Euphoria routines and they worked fine! > > In my main program I coded a routine to kick off the task and then wait until > it was complete: > > }}} <eucode> > task = task_create(routine_id("execute_task"), {invoked_from, ctl_index}) > task_schedule(task,1) > -- Process message loop until end of task > while find(task, task_list()) do > doEvents(0) > task_yield() > end while > </eucode> {{{ > > Carefully placed task_yield() calls, both in the main program and in Win32Lib > seemed to keep things in order. > > I did have to rework a HUGE portion of my code to eliminate my over-use of > globals. > But that was my issue, not tdll. I just had to ensure that one task would > not interfere with the values in another task. > > I was having some problems at first before I figured out how to place calls > to task_yield() and Daniel suggested his APC DLL which he said was better than > TDLL but I could not figure out how to use the library and never got a > response > back from him on a request for documentation. I just found the TDLL calls > easier > to understand. > > HTH, > > Jonas Temple > <a href="http://www.innovativesys.net">http://www.innovativesys.net</a> Sure does. And perhaps the next win32lib version could have a task_yield() in doEvents(), provided there is a zero time way to prevent the call from Eu intrepreters that don't support task_yield. I didn't test, but OTOH I'd hink the task_yield() n the message loop is overkill and could eat some CPU as it would be executed often for no benefit. . You appear to be well placed o test whether it is necessary to leave that call there. Thanks for the detailed reply. CChris
10. Re: Non Blocking Support
- Posted by Jonas Temple <jtemple at yhti.net> Feb 15, 2007
- 621 views
- Last edited Feb 16, 2007
CChris wrote: > Sure does. And perhaps the next win32lib version could have a task_yield() > in doEvents(), provided there is a zero time way to prevent the call from > Eu intrepreters that don't support task_yield. > I didn't test, but OTOH I'd hink the task_yield() n the message loop is > overkill and could eat some CPU as it would be executed often for no benefit. > . You appear to be well placed o test whether it is necessary to leave that > > call there. Maybe Rob could comment on the overhead of repeating task_yield()? One possible solution is to have a routine in Win32Lib that could turn on/off the task_yield() call by the programmer. That way when you have more than 1 task running (other than the main task) you could turn on task_yield() and then turn off when the secondary tasks have completed. Rob, everything I've seen from the tasking system seems to work just fine. I did run into some very strange results where Euphoria variables would appear to be changed in the middle of a routine but I think that had to do more with timing of the tasks. It would be nice if the debugger would show you what task you're debugging. I think any time you add tasking to a Windows based program it will not be a trivial change. Careful consideration will have to be given. If I had my way, we'd have threads in EU but I don't think that will happen. > > Thanks for the detailed reply. Glad to help! Jonas Temple http://www.innovativesys.net
11. Re: Non Blocking Support
- Posted by Robert Craig <rds at RapidEuphoria.com> Feb 16, 2007
- 636 views
Jonas Temple wrote: > CChris wrote: > > Sure does. And perhaps the next win32lib version could have a task_yield() > > in doEvents(), provided there is a zero time way to prevent the call from > > Eu intrepreters that don't support task_yield. > > I didn't test, but OTOH I'd hink the task_yield() n the message loop is > > overkill and could eat some CPU as it would be executed often for no > > benefit. > > . You appear to be well placed o test whether it is necessary to leave that > > > > call there. > > Maybe Rob could comment on the overhead of repeating task_yield()? With no tasks created (other than the single main task that all programs now have), on my 1.8 GHz P4, I can do 4 million task_yields per second using exw.exe. (1/4 microsecond each). So if you were somehow doing, say, 100,000 events per second (10 microseconds each) the overhead of 1/4 of a microsecond, would be 2.5% Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com