Boost logo

Boost :

Subject: Re: [boost] [context review] Several Questions
From: Oliver Kowalke (oliver.kowalke_at_[hidden])
Date: 2011-03-21 09:14:31


> > sched_yield(): 2108 cycles
> > ucontext_t: 1795 cycles
> > fcontext_t: 156 cycles
> >

> Actually it is quite consistent with what you had show,
> the Boost.Context is better (but not significantly) then
> real OS (kernel) context switch.

factor 13x ?

> It would be very useful to see real usability cases. Because otherwise
> it is hard to estimate usefulness of this library

The lib is intended to be a building block for higher abstractions like coroutines.

> I understand, it may be useful for "yeild" like iterators and so
> but it is not clear how does it work and what is the advantage
> in comparison to ordinary event driven approach.

I remember that factor (http://factorcode.org/) does context switching for its internal working.

You can preserve local data:

void myfunc()
{
   for ( int i = 0; i< 10; ++i)
   {
      if ( 5 == i)
yield();

-- 
GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit 
gratis Handy-Flat! http://portal.gmx.net/de/go/dsl

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk