[XviD-devel] hey I'm back :)
Skal
skal at planet-d.net
Mon Nov 21 14:33:43 CET 2005
Hi Radek! :)
On Mon, 2005-11-21 at 11:38, Radek Czyz wrote:
> Hey,
>
> Michael Militzer wrote:
> > Also, Skal is working on multithreaded code and has made a lot (good and
> > bad) experiences with this recently. So you should check how your ideas
> > here overlap (or not) just to make sure you don't do things twice...
>
> Bah, there goes my fun/learning ;)
>
> I mostly want to know *how* to write such code, so even if things
> repeat, it's not a huge loss.
>
> Skal: what have you done? ^_^
Ok, you take me by surprise, but anyway i'll just
post here the helpers for MT i was preparing for
XviD. It's mainly 2 files (slave.h and slave.c)
that belongs to the /utils/ directory. They are
not in a 'committable' state, but i think you
can play with them. The API for using a 'slave'
thread is rather simple:
ThreadWorker slave;
xvThreadInit(&slave); // creates a sleeping thread, hereby called 'slave'
// prepare a workload to give the to the slave when times come
ThreadWorkerData work;
work._Call = myParallelFunc;
work._Int1 = some param to be passed ...
// schedule the parallel task
xvThreadSetTodo(&slave, &work);
// do something else while the slave is working...
...
// sync everybody
xvThreadSync(&slave);
// finish
xvThreadEnd(&slave);
Now the func to be executed in parallel look something like:
void *myParallelFunc(ThreadWorkerData *data)
{
int myParam = data->_Int1;
// etc...
/// do something
return 0; // success. Return something !=0 to abort MT.
}
Well, i think it's close to useful, notwithstanding
the bugs of course! Haf phun!
bye,
Skal
(for the experiments i made, it'll take another (somewhat longer;) mail)
More information about the XviD-devel
mailing list