Ri-Ping YU | 24 Mar 09:34 2015
Picon

How can I get demo for Libev

Hi, everyone
    We're trying to adopt "Libev" in our project, but I have not found any demo for it.
    I want to know how can I start with "Libev", and how can I design my program with it.

    Appreciate for any response!

    Thanks!
_______________________________________________
libev mailing list
libev <at> lists.schmorp.de
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
Ri-Ping YU | 24 Mar 08:15 2015
Picon

Error while cross-compiling

Hi, everyone
    I'm trying to adopt Libev in my project. But one error occured while cross-compiling, Log is below

----------------------------------------------------------------

root <at> YRP-ES-QD:/opt/DevelopmentTraining/Subjects/Libev/libev-4.19# ./configure --host=arm-none-linux-gnueabi --prefix=/opt/TestCell/Temp 
checking for a BSD-compatible install... /usr/bin/install -c 
checking whether build environment is sane... yes 
checking for arm-none-linux-gnueabi-strip... arm-none-linux-gnueabi-strip 
checking for a thread-safe mkdir -p... /bin/mkdir -p 
checking for gawk... gawk 
checking whether make sets $(MAKE)... yes 
checking whether make supports nested variables... yes 
checking whether to enable maintainer-specific portions of Makefiles... no 
checking for arm-none-linux-gnueabi-gcc... arm-none-linux-gnueabi-gcc 
checking whether the C compiler works... yes 
checking for C compiler default output file name... a.out 
checking for suffix of executables... 
checking whether we are cross compiling... yes 
checking for suffix of object files... o 
checking whether we are using the GNU C compiler... yes 
checking whether arm-none-linux-gnueabi-gcc accepts -g... yes 
checking for arm-none-linux-gnueabi-gcc option to accept ISO C89... none needed 
checking whether arm-none-linux-gnueabi-gcc understands -c and -o together... yes 
checking for style of include used by make... GNU 
checking dependency style of arm-none-linux-gnueabi-gcc... gcc3 
checking build system type... i686-pc-linux-gnu 
checking host system type... arm-none-linux-gnueabi 
checking how to print strings... printf 
checking for a sed that does not truncate output... /bin/sed 
checking for grep that handles long lines and -e... /bin/grep 
checking for egrep... /bin/grep -E 
checking for fgrep... /bin/grep -F 
checking for ld used by arm-none-linux-gnueabi-gcc... /opt/DVRRDK/DVRRDK_03.00.00.00/ti_tools/cgt_a8/arm-2009q1/arm-none-linux-gnueabi/bin/ld 
checking if the linker (/opt/DVRRDK/DVRRDK_03.00.00.00/ti_tools/cgt_a8/arm-2009q1/arm-none-linux-gnueabi/bin/ld) is GNU ld... yes 
checking for BSD- or MS-compatible name lister (nm)... /opt/DVRRDK/DVRRDK_03.00.00.00/ti_tools/cgt_a8/arm-2009q1/bin/arm-none-linux-gnueabi-nm -B 
checking the name lister (/opt/DVRRDK/DVRRDK_03.00.00.00/ti_tools/cgt_a8/arm-2009q1/bin/arm-none-linux-gnueabi-nm -B) interface... BSD nm 
checking whether ln -s works... yes 
checking the maximum length of command line arguments... 1572864 
checking whether the shell understands some XSI constructs... yes 
checking whether the shell understands "+="... yes 
checking how to convert i686-pc-linux-gnu file names to arm-none-linux-gnueabi format... func_convert_file_noop 
checking how to convert i686-pc-linux-gnu file names to toolchain format... func_convert_file_noop 
checking for /opt/DVRRDK/DVRRDK_03.00.00.00/ti_tools/cgt_a8/arm-2009q1/arm-none-linux-gnueabi/bin/ld option to reload object files... -r 
checking for arm-none-linux-gnueabi-objdump... arm-none-linux-gnueabi-objdump 
checking how to recognize dependent libraries... pass_all 
checking for arm-none-linux-gnueabi-dlltool... no 
checking for dlltool... no 
checking how to associate runtime and link libraries... printf %s\n 
checking for arm-none-linux-gnueabi-ar... arm-none-linux-gnueabi-ar 
checking for archiver <at> FILE support... <at>  
checking for arm-none-linux-gnueabi-strip... (cached) arm-none-linux-gnueabi-strip 
checking for arm-none-linux-gnueabi-ranlib... arm-none-linux-gnueabi-ranlib 
checking command to parse /opt/DVRRDK/DVRRDK_03.00.00.00/ti_tools/cgt_a8/arm-2009q1/bin/arm-none-linux-gnueabi-nm -B output from arm-none-linux-gnueabi-gcc object... ok 
checking for sysroot... no 
checking for arm-none-linux-gnueabi-mt... no 
checking for mt... mt 
configure: WARNING: using cross tools not prefixed with host triplet 
checking if mt is a manifest tool... no 
checking how to run the C preprocessor... arm-none-linux-gnueabi-gcc -E 
checking for ANSI C header files... yes 
checking for sys/types.h... yes 
checking for sys/stat.h... yes 
checking for stdlib.h... yes 
checking for string.h... yes 
checking for memory.h... yes 
checking for strings.h... yes 
checking for inttypes.h... yes 
checking for stdint.h... yes 
checking for unistd.h... yes 
checking for dlfcn.h... yes 
checking for objdir... .libs 
checking if arm-none-linux-gnueabi-gcc supports -fno-rtti -fno-exceptions... no 
checking for arm-none-linux-gnueabi-gcc option to produce PIC... -fPIC -DPIC 
checking if arm-none-linux-gnueabi-gcc PIC flag -fPIC -DPIC works... yes 
checking if arm-none-linux-gnueabi-gcc static flag -static works... yes 
checking if arm-none-linux-gnueabi-gcc supports -c -o file.o... yes 
checking if arm-none-linux-gnueabi-gcc supports -c -o file.o... (cached) yes 
checking whether the arm-none-linux-gnueabi-gcc linker (/opt/DVRRDK/DVRRDK_03.00.00.00/ti_tools/cgt_a8/arm-2009q1/arm-none-linux-gnueabi/bin/ld) supports shared libraries... yes 
checking whether -lc should be explicitly linked in... no 
checking dynamic linker characteristics... GNU/Linux ld.so 
checking how to hardcode library paths into programs... immediate 
checking whether stripping libraries is possible... yes 
checking if libtool supports shared libraries... yes 
checking whether to build shared libraries... yes 
checking whether to build static libraries... yes 
checking sys/inotify.h usability... yes 
checking sys/inotify.h presence... yes 
checking for sys/inotify.h... yes 
checking sys/epoll.h usability... yes 
checking sys/epoll.h presence... yes 
checking for sys/epoll.h... yes 
checking sys/event.h usability... no 
checking sys/event.h presence... no 
checking for sys/event.h... no 
checking port.h usability... no 
checking port.h presence... no 
checking for port.h... no 
checking poll.h usability... yes 
checking poll.h presence... yes 
checking for poll.h... yes 
checking sys/select.h usability... yes 
checking sys/select.h presence... yes 
checking for sys/select.h... yes 
checking sys/eventfd.h usability... yes 
checking sys/eventfd.h presence... yes 
checking for sys/eventfd.h... yes 
checking sys/signalfd.h usability... yes 
checking sys/signalfd.h presence... yes 
checking for sys/signalfd.h... yes 
checking for inotify_init... yes 
checking for epoll_ctl... yes 
checking for kqueue... no 
checking for port_create... no 
checking for poll... yes 
checking for select... yes 
checking for eventfd... yes 
checking for signalfd... yes 
checking for clock_gettime... no 
checking for clock_gettime syscall... yes 
checking for nanosleep... yes 
checking for library containing floor... -lm 
checking that generated files are newer than configure... done 
configure: creating ./config.status 
config.status: creating Makefile 
config.status: creating config.h 
config.status: executing depfiles commands 
config.status: executing libtool commands 
root <at> YRP-ES-QD:/opt/DevelopmentTraining/Subjects/Libev/libev-4.19# make CROSS_COMPILE=arm-none-linux-gnueabi- ARCH=arm 
make all-am 
make[1]: Entering directory `/opt/DevelopmentTraining/Subjects/Libev/libev-4.19' 
/bin/sh ./libtool --tag=CC --mode=compile arm-none-linux-gnueabi-gcc -DHAVE_CONFIG_H -I. -g -O3 -MT ev.lo -MD -MP -MF .deps/ev.Tpo -c -o ev.lo ev.c 
libtool: compile: arm-none-linux-gnueabi-gcc -DHAVE_CONFIG_H -I. -g -O3 -MT ev.lo -MD -MP -MF .deps/ev.Tpo -c ev.c -fPIC -DPIC -o .libs/ev.o 
ev.c:1314:3: error: #error "memory fences not defined for your architecture, please report" 
ev.c:1625: warning: 'ev_default_loop_ptr' initialized and declared 'extern' 
make[1]: *** [ev.lo] Error 1 
make[1]: Leaving directory `/opt/DevelopmentTraining/Subjects/Libev/libev-4.19' 
make: *** [all] Error 2 

--------------------------------------------------------------------------------------------------------------------------------

    How can I solve this problem? 
    Appreciate for any response!

_______________________________________________
libev mailing list
libev <at> lists.schmorp.de
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
Jamal Hadi Salim | 20 Mar 19:28 2015

clang c11

clang with c11 enforcement (clang -Wall -g -O -std=c11) pukes on:

./ev.c:3814:26: error: use of undeclared identifier 'SIG_UNBLOCK'
             sigprocmask (SIG_UNBLOCK, &sa.sa_mask, 0);
                          ^
(slightly dated ev.c - but inspecting the latest tree, same issue there)

looking at the man pages for sigprocmask on linux:
sigprocmask() requires one of:
_POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE

It is trivial to pick one of the above and #define in ev.c but i dont
want to diverge on a private tree.
Is there some compile option perhaps i should be passing to make this go
away?

cheers,
jamal
Nick Zavaritsky | 12 Mar 19:22 2015
Picon

Unexpected periodic invocation of ev_check watcher

Dear List,

I have an ev_check watcher in my event loop and it gets invoked approximately every minute or so.
There is no other activity happening and I assume that the loop should just stay idle instead.

Is it the intended behavior?

Regards.

PS. The code sample.

#include <ev.h>
#include <stdio.h>

void cb(struct ev_loop* loop, struct ev_check* instance, int revents)
{
    printf("ev_check\n");
}

int main()
{
    struct ev_check c;

    ev_check_init(&c, cb);

    ev_check_start(ev_default_loop(0), &c);

    ev_loop(ev_default_loop(0), 0);

    return 0;
}
Rick van Rein | 14 Feb 15:47 2015
Picon

Fwd: Driving a thread pool from libev

Hi,

> Excellent solution, it indeed avoid memcpy().

Thanks :-D

Conceptually the most logical model would be if libev would run multiple callbacks, each running in
workers from the thread pool; and if it would use this mechanism to avoid starting multiple such callbacks
on a single watcher.

> When you say "yeild()", it's some notification like ev_async_send(), right?

Not quite.  My thinking was that a main thread could spark off multiple callback threads, but these may not
have run when the main thread loops back for another poll() invocation.  This would be sure to give all
sparked-off threads an opportunity to remove the revents from the watcher.  Only threads that don’t act
on their watcher's revents in time would be temporarily removed from the poll() list.  When the threaded
callback finished, they would of course be added back in the poll() list.

The ideal is to run this pthread_yield() once per thread, just before returning to poll() — calling it
from every callback function is possible, but wasteful as a single round over all threads is sufficient
for each invocation of poll().  I don’t know yet if there are macro’s I can define to do that.

I’m thinking even further… the main thread could simply be one from the thread pool.  It would start off
other slaves, until there’s more work then it has slaves for, in which case it would degrade itself to a
slave.  Finishing slaves would take out one further event in turn, until the last is consumed; by that time,
the slave promotes itself to be the new master, and returns to poll().  This makes threads continue to run in
many cases, which means that the opportunity for lock-free or spinlock-based control is high.  Only when a
thread really needs to wait would it be beneficial to wait for locks.  Sort of the “sleeping barber”
setup, where clients volunteer as barbers :)

This stuff is fun :-D

It’s a pitty libev doesn’t do all this yet though; it feels like a natural extension to me.

Cheers,
-Rick

_______________________________________________
libev mailing list
libev <at> lists.schmorp.de
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
Rick van Rein | 14 Feb 10:10 2015
Picon

Driving a thread pool from libev

Hello,

I am trying to drive a thread pool from libev, but the design appears to be impossible; or has anyone no this
list done this before?

The application: a TLS Pool [1], with worker threads that read(), then encrypt or decrypt, then write(). 
The workers should be part of a thread pool.  And, assuming that read() is a bit costly [2], I am trying to do
even that operation in the worker threads.

	[1] http://tlspool.arpa2.net
	[2] when the data is not buffered, and also because data would flow through an intermediate buffer causing
an extra copy operation

When work is offloaded to the thread pool, the callback from libev can return and would hopefully cause
other work to be queued, thus keeping the thread pool occupied with encryption/decryption.  The problem
is, I am not sure if libev will avoid triggering an object that has already been queued, since poll() and
friends will return a read opportunity over and over again.  And AFAIK I cannot tell libev to temporarily
stop calling back on a watcher, except by taking it out completely — which I presume is an expensive operation.

The current design uses a thread for each TLS connection, which is wasteful of memory, and this is why I am
looking to create a thread pool with a limited number of shared workers.  I could decide to do the read() in
the callback, if need be, but have not quite given up on a more efficient approach.  Has anyone on this list
seen such a setup with libev?

Thanks,

Rick van Rein
ARPA2.net

_______________________________________________
libev mailing list
libev <at> lists.schmorp.de
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
Dmitry Marakasov | 4 Feb 21:33 2015
Picon

Incorrect C11 / cannot build with clang 3.6

Hi!

I'm testing new version of clang (3.6) on various software, and
libev doesn't build with it:

---
libtool: compile:  clang36 -DHAVE_CONFIG_H -I. -O2 -pipe -march=nocona -fstack-protector
-fno-strict-aliasing -MT ev.lo -MD -MP -MF .deps/ev.Tpo -c ev.c  -fPIC -DPIC -o .libs/ev.o
ev.c:477:48: warning: '/*' within block comment [-Wcomment]
/*#define MIN_INTERVAL  0.00000095367431640625 /* 1/2**20, good till 2200 */
                                               ^
ev.c:970:42: error: '_Noreturn' keyword must precede function declarator
  ecb_inline void ecb_unreachable (void) ecb_noreturn;
                                         ^~~~~~~~~~~~
  _Noreturn 
ev.c:773:26: note: expanded from macro 'ecb_noreturn'
  #define ecb_noreturn   _Noreturn
---

Seems like C11 is now the default, however libev code is incorrect
C11-wise, as ecb_noreturn which expands to _Noreturn follows function
definition, while _Noreturn should preceed it.

Depending on whether it's allowed to place __attribute__ before
function, either ecb_noreturn should be moved before ecb_unreachable
declaration, or it should be split to e.g. ecb_pre_noreturn and
ecb_post_noreturn to work for both cases.

Full log with clang 3.4:
https://people.freebsd.org/~amdmi3/libev-clang34.log

Full log with clang 3.6:
https://people.freebsd.org/~amdmi3/libev-clang36.log

--

-- 
Dmitry Marakasov   .   55B5 0596 FF1E 8D84 5F56  9510 D35A 80DD F9D2 F77D
amdmi3 <at> amdmi3.ru  ..:  jabber: amdmi3 <at> jabber.ru    http://www.amdmi3.ru
Dinesh RTP | 22 Jan 06:22 2015
Picon

1/22/2015 5:22:31 AM




http://www.stainlesssteelfabricator.co.uk/tcnxvdmo/cbgdxoljksdqt.umdrdnwxlfgtuovrjkkjshsxyricq




















Dinesh RTP
1/22/2015 5:22:31 AM
_______________________________________________
libev mailing list
libev <at> lists.schmorp.de
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
Hayk Martirosyan | 20 Jan 02:33 2015
Picon

while(true) { ev_run(loop, EVRUN_NOWAIT); } much faster than ev_run(loop);

I'm using libev in a high-performance application, and I've noticed against my expectation that looping ev_run with EVRUN_NOWAIT handles events 5x faster than calling ev_run without the loop. Is this expected behavior?

Best,
Hayk
_______________________________________________
libev mailing list
libev <at> lists.schmorp.de
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
biliucheng@diditaxi.com.cn | 12 Jan 09:10 2015
Picon

a question when using libev

hi
    I encount a problem when using libev. In a callback function, I want to modify the fd's events.
    I try to use ev_io_set and ev_io_start, but it doesnot work. 
    From libev's code, I guess backend_modify can do it, but it is not an outter interface.
    Could you tell me what  I should do?

Thank you 

biliucheng <at> diditaxi.com.cn
_______________________________________________
libev mailing list
libev <at> lists.schmorp.de
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
Alexander Klauer | 8 Jan 10:45 2015
Picon

ev_io events doc clarification

Hi,

I'd like to suggest the following clarification to the docs:

cvs diff: Diffing .
Index: ev.pod
===================================================================
RCS file: /schmorpforge/libev/ev.pod,v
retrieving revision 1.434
diff -u -r1.434 ev.pod
--- ev.pod	6 May 2014 13:24:39 -0000	1.434
+++ ev.pod	8 Jan 2015 09:34:56 -0000
 <at>  <at>  -1749,7 +1749,9  <at>  <at> 

 =item int events [read-only]

-The events being watched.
+The events being watched. May contain additional (internal) event flags
+besides C<EV_READ> and C<EV_WRITE>, so make sure you use bitmasks when
+you check this member.

 =back

Best regards,
Alexander

Gmane