Project

General

Profile

Actions

Feature #2512

closed

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

Added by pespin over 6 years ago. Updated almost 6 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
09/14/2017
Due date:
% Done:

100%

Spec Reference:

Description

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 approachNewpespin05/04/2018

Actions
Actions #1

Updated by neels over 6 years ago

+1

Actions #2

Updated by pespin almost 6 years ago

As far as I could see now, it seems the best idea will be to re-use some of the code in modem.py and move it to event_loop.py 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:
https://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html
https://blogs.gnome.org/desrt/2012/05/09/glib-mainloop-sources-in-python-e-g-for-irclib/

Actions #3

Updated by pespin almost 6 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:   https://gerrit.osmocom.org/7559 event_loop: Use glib as mainloop impl and move modem to use event_loop
remote:   https://gerrit.osmocom.org/7560 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.

Actions #4

Updated by pespin almost 6 years ago

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

Updated by pespin almost 6 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.

Actions

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 48.8 MB)