[CCC DEV] Reuse vs. reimplementation
Carl Ritson
C.G.Ritson at kent.ac.uk
Fri Sep 23 10:53:20 BST 2011
Hi Matt and Zach,
> We've started to study the CCSP runtime. It is... more opaque than the
> TVM, perhaps because a fair bit of work is lifted up into tranx86.
> That aside, it looks like the work-stealing scheduler lives in sched.c
> in a fairly clean form.
Yes, generally all the work is in sched.c, with some macros that do
the assembly. The way occam is compiled is messy at best, so yes it
can be fairly opaque overall. The TVM suffers because of that too, but
once you know exactly what each instruction _should_ do then you have
gathered most of the knowledge you need.
> This led us to start wondering: is it a better software engineering
> approach to begin with your code, and work on adapting it into the TVM
> runtime? Or, is there a simpler formulation of the wait-free
> work-stealing algorithm that would be more appropriate for the TVM? As
> we look at your code, we realize that there is quite a bit going on:
> things are HOT or TEPID, and a lot of basic accounting and linking
> work to maintain all of the structures that are opportunities for
> error if we start from scratch.
A lot of the stuff macro based stuff like HOT/TEPID is for
optimisation or linking.
Particularly as the calling prototypes have changed several times
(and/or I was testing different ones), lots of things went in to
macros so I could tweak all the code together.
> Our goal is a platform-portable implementation of this algorithm.
> Zach's motivation is to learn more about C, scheduling, and the work
> involved in bringing software to an embedded target... hence, our
> formulation of this project. What would you advise in this context?
> Port and adapt existing code? Start clean? Find someone else to bother
> with our questions? ;)
That is indeed a difficult question.
If you want to lift something and for it to work, then you probably
need to take all the algorithms (not code) as they are, in which case
cribbing from CCSP is the way to go. Work-stealing isn't the hard part
(in my opinion), it's the wait-free aspect, for which you need atomic
operations and architecture understanding.
More information about the developers
mailing list