On 20/08/2014, at 12:17 AM, srean wrote:
> Could you describe the performance characteristic of reading from or writing
> to an schannel. Is it fair to assume its going to be no more expensive than
> writing/reading through a pointer (sans the scheduling delays).
The library reads/writes values, the operation pointers, so the library
makes a heap copy on write. Dispatch is through a couple of levels
of the RTL, the final code is here, in src/rtl/flx_sync.cpp:
void sync_sched::do_sread()
{
readreq_t * pr = (readreq_t*)request->data;
schannel_t *chan = pr->chan;
if(debug_driver)
fprintf(stderr,"[sync: svc_read] Request to read on channel %p\n",chan);
if(chan==NULL) goto svc_read_none;
svc_read_next:
{
fthread_t *writer= chan->pop_writer();
if(writer == 0) goto svc_read_none; // no writers
if(writer->cc == 0) goto svc_read_next; // killed
readreq_t * pw = (readreq_t*)writer->get_svc()->data;
if(debug_driver)
fprintf(stderr,"[sync: svc_read] Writer @%p=%p, read into %p\n",
pw->variable,*(void**)pw->variable, pr->variable);
*(void**)pr->variable = *(void**)pw->variable;
// reader goes first!
active->push_front(writer);
collector->add_root(writer);
return;
}
svc_read_none:
if(debug_driver)
fprintf(stderr,"[sync: svc_read] No writers on channel %p:
BLOCKING\n",chan);
chan->push_reader(ft);
forget_current();
return;
}
The write operation is similar.
--
john skaller
[email protected]
http://felix-lang.org
------------------------------------------------------------------------------
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language