On 31/03/2011, at 7:13 PM, Rhythmic Fistman wrote: > > The "real" driver is an opaque blob inside that contains the gc data, > and active fthreads. > It also contains a "ticker", a felix schannel[int] that when read from > returns the current tick (of the game - it's a game). The tick is > actually ignored; reading only serves to deschedule the fthread until > the next tick.
This is the correct way to do it. > > Later the driver unblocks the fthreads by simulating n channel writes: You should be able to do that in Felix, to reduce the external scheduling to a single entity... > > I tried to implement this step in felix: Ah .. great minds or something .. :) > > gen has_reader[t]: schannel[t] -> bool = "$1->waiting_to_read->head != NULL"; > > // this isn't quite working, can't be run by simple continuation execution, > // needs own svc savvy driver, which is a bit too second order for me. also > // getting gc error: "removed non root". > private proc flx_unblock_all(tick: int, npopped: &int) { > var n = 0; > > while{ has_reader(ticker) } { // peek readers so we don't desched > n++; > write(ticker, tick); // pop a reader > }; > > *npopped = n; > } > > but it never quite worked. Do it the right way: you need a schannel for *each* fthread. Keep the write end in a varray and loop through them. This gives you control over order of execution, even better, with a more sophisticated data structure, you can execute some things more often. Now, the fthread that owns this array: whilst it is active, none of the fthreads connected to it via the array can be descheduled. If you want to deschedule one, just remove it from the array .. the GC will clean it up automatically. You could use the new 'sarray', that's a sparse array int->T. Very efficient (uses Judy to map integer to value). Anyhow, now you have reduced the problem to ticking the "scheduler" thread. Initially, you could just do that the old way. -- john skaller skal...@users.sourceforge.net ------------------------------------------------------------------------------ Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language