On 04.06.2014 16:13, Franck Jullien wrote:
> 2014-06-04 15:08 GMT+02:00 Franck Jullien <franck.jull...@gmail.com>:
>> Hi,
>>
>> I'm implementing support for an UART over JTAG module present in the
>> OpenRISC debug interface. It's a device which looks like an UART on
>> the SoC Wishbone bus but which transfers data via JTAG.
>>
>> I have created a new telnet sever for that and it works fine.
>>
>> My problem is how the polling function is called. I'm using:
>>
>> target_register_timer_callback(&jsp_poll_read, 1, 1, jsp_service);
>>
>> however, due to socket_select bloking for 100ms in server_loop [1] it
>> does not poll every 1ms.
>>
>> I could rewrite the server_loop to include a "fast_poll" handler.
>>
>> I could also use a polling thread in my jsp_server. I guess if I use
>> thread functions, I would need to add those in src/helper and create
>> proper wrapper to make things work under Linux a Windows.
I prefer the polling thread, provided this does not cause too much
problems due to windows compatibility.

>
> diff --git a/src/server/server.c b/src/server/server.c
> index 01e8441..f4a34d8 100644
> --- a/src/server/server.c
> +++ b/src/server/server.c
> @@ -380,8 +380,8 @@ int server_loop(struct command_context *command_context)
>                         tv.tv_usec = 0;
>                         retval = socket_select(fd_max + 1, &read_fds,
> NULL, NULL, &tv);
>                 } else {
> -                       /* Every 100ms */
> -                       tv.tv_usec = 100000;
> +                       /* Every 1ms */
> +                       tv.tv_usec = 1000;
>                         /* Only while we're sleeping we'll let others run */
>                         openocd_sleep_prelude();
>                         kept_alive();
>
> Is that ok ?
I don't like that approach - this will waste CPU cycles on slow
machines, even if there is noone that needs the fast poll interval. If
you make this conditional and switch to the fast polling only if there
is some callback registered that needs it, then this should be OK.

cu
Michael


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their 
applications. Written by three acclaimed leaders in the field, 
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to