Feature #2512

osmo-gsm-tester: Convert event_loop.wait to support passive polling

Added by pespin over 3 years ago. Updated over 2 years ago.

Target version:
Start date:
Due date:
% Done:


Spec Reference:


Right now, all polling in osmo-gsm-tester is done by sleeping small amounts of times (like 0.1 seconds), then calling poll function everywhere. Some of those poll functions are actually event-based (like glib main loop, or any fd/socket being used) and can be monitored with select() instead of using active polling. This way we avoid wasting resources and we avoid delaying signal-driven events.

For objects not supporting passive polling, we should provide an API to create a timer object (man timerd_create ?) and just call select() on those.

Related issues

Related to OsmoGSMTester - Feature #3234: osmo-gsm-tester: poll the python-smpplib socket using non-busy approachNew05/04/2018


#1 Updated by neels over 3 years ago


#2 Updated by pespin almost 3 years ago

As far as I could see now, it seems the best idea will be to re-use some of the code in and move it to to have an EventLoop class and public global functions which use a global instance of that object.

This EventLoop will contain a glib main loop inside. It will call glib_main_loop.iterate() every time we want to poll. New methods will be added to be able to register fds for passive polling instead of only having active polling functions. Also we will add methods to add/remove timer callbacks. We can then fire active polling every 0.1 seconds by using the timer registered function, and we can use the same to implement the wait() API we already have.

The idea is to slowly move required active polling users (python-smpp fd, wait(), sleep(), etc.) to use passive polling/timers.

Also interesting to look at GSource to implement management of all the fds/poll functions:

#3 Updated by pespin almost 3 years ago

  • Status changed from New to Feedback
  • % Done changed from 0 to 60

Patches re-implementing event_loop wait() and sleep() using glib loop have been usbmited to gerrit:

remote: event_loop: Use glib as mainloop impl and move modem to use event_loop
remote: Drop event_loop global functions and import MainLoop

With this code, we remove part of busy polling and from here we can easily add a register_fd() and unregister_fd() APIs to event_loop to be able to use passive polling with any source using an FD. We can even implement GSource subclasses.

#4 Updated by pespin over 2 years ago

  • Related to Feature #3234: osmo-gsm-tester: poll the python-smpplib socket using non-busy approach added

#5 Updated by pespin over 2 years ago

  • Status changed from Feedback to Resolved
  • % Done changed from 60 to 100

A new more specific task #3234 has been created to move users of event_loop which can potentially use FDs as event triggers.

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 48.8 MB)