[gephex-devel] scheduler in gephex-0.5

Georg Seidel georg at gephex.org
Sun Nov 6 10:23:40 CET 2005


Hi all,

I had an idea regarding a scheduler architecture for gephex-0.5.

In this context, the term scheduler denotes the component that
decides when to update an effect graph.
A very simple scheduler would be one that tells the core to update
every 1/25 th second for achieving a constant fps of 25.

We already decided in discussions some time ago, that we want the
scheduler component to be exchangable and not hardcoded in the
core.
Useful schedulers we discussed so far:

  - constant fps scheduler (as mentioned above)
  - jack driven scheduler (will tell core to update whenever the
      jack server wants us to create a frame)
  - offline scheduler (to do non-realtime, offline rendering)

I'm sure, there are many more possible schedulers.


Now regarding the idea I had. It has two parts.

Part 1: I propose to use our plugin system
and to introduce a new type Scheduler in addition to the existing
types Unit, LinkFactory, and Link.
The interface of the new type will be similar to a Unit. It will
have ports (input only) which allow to attach types.
Instead of an update function, it will have a wait() function,
which blocks until the next update should be done.
(Maybe also a try_wait() functions for polling?)

Let's go back to the example of the constant fps scheduler.
It could be implemented with one input of type Number, which
allows to control the fps. The wait() method could look like

 void ConstantFPSScheduler::wait(const Number& fps)
 {
    sleep_ms(1000. / fps.value());
 }

(this is a very simple and inaccurate implementation of course, but
you get the general idea).

The jack-controlled scheduler would need a special input type that
allows it to know when the jack server wants an image from us.
This could be the internal state of the jack output unit for example.


To use the new scheduler types, we need the second part of my
proposal: add functionality to the core to instantiate Scheduler
objects and to use one Scheduler object as the active Scheduler.
In a konsolenphex session, this could look like that:

  > ls
  (libcore;)
  > load(libcore)
  UnitFactories: (Kalkulon,1;) -
  LinkFactories: (NumberFactory,1;TextFactory,1;BGRAImageFactory,1;) -
  Schedules: (ConstantFPSScheduler,1;)
  > sc_import(ConstantFPSScheduler,1)
  ConstantFPSScheduler:1
  > sc_create(scheduler, ConstantFPSSchedule:1)
  Created Scheduler 'scheduler'
  [...] // create a Number object called fps
  > attach(fps, scheduler, in_fps, c1)         // connect the fps type
  c1
  > set_active_scheduler(scheduler)
  scheduler
  > run()
  running...


Open questions:

  - How exactly will the core use the active schedule?
    The core must still be able to respond to commands, so maybe it is
    not possible to call Schedule::wait() from the main thread.

  - Do we need polling in the Schedule interface? Or should the wait
    method have a timeout parameter?


Regards,

Georg


More information about the gephex-devel mailing list