Re: [9fans] rsc's libtask on embedded

2015-07-09 Thread erik quanstrom
all process-like implementations except if they give up on per-cpu 
multiprogramming are setjmp based at heart.

- erik


On Jul 9, 2015 09:31, Bakul Shah  wrote:
>
> Your use is different and simple enough that I would suggest doing this from 
> scratch in pure C. Or start from an existing setjmp based implementation. It 
> should really be a couple pages of code at most. 
>
> > On Jul 9, 2015, at 9:12 AM, "st...@quintile.net"  
> > wrote: 
> > 
> > co routines plus channels is exactly what I want. 
>
>


Re: [9fans] rsc's libtask on embedded

2015-07-09 Thread Skip Tavakkolian
i would be interested (purely out of curiosity and for learning) to
see a simple test using libtask targeting something like
qemu-system-arm emulating a virtual board like VersatilePB[1] or
simpler system.  i think that would be cool demo.

[1] 
http://infocenter.arm.com/help/topic/com.arm.doc.dui0224i/DUI0224I_realview_platform_baseboard_for_arm926ej_s_ug.pdf




Re: [9fans] rsc's libtask on embedded

2015-07-09 Thread Bakul Shah
Your use is different and simple enough that I would suggest doing this from 
scratch in pure C. Or start from an existing setjmp based implementation. It 
should really be a couple pages of code at most.

> On Jul 9, 2015, at 9:12 AM, "st...@quintile.net"  wrote:
> 
> co routines plus channels is exactly what I want.



Re: [9fans] rsc's libtask on embedded

2015-07-09 Thread st...@quintile.net
I looked at proto, they are just state machines pretending to be threads (imho) 
- not my style.

libtask for me, I hope I can slice it a little and put the non-bear-metal bits 
in seperate files so I can offer the changes back.

co routines plus channels is exactly what I want.

-Steve





> On 9 Jul 2015, at 16:58, Joseph Stewart  wrote:
> 
> One other thing that I've looked at but never used is Adam Dunkels' 
> "protothreads" (http://dunkels.com/adam/pt/) although you'd still need to 
> roll your own channel library.
> 
>> On Thu, Jul 9, 2015 at 10:50 AM, Steve Simon  wrote:
>> The system I am trying to add libtask to has no runtime other than libc.
>> 
>> Corrently it is an even based system that uses a "min main loop" and
>> a twisty maze of nested state machines that all look the same.
>> 
>> Hence my desire to add co-routines + channels (i.e. exactly what libtask is)
>> to it. I have no need for the file or network modules but those are easily 
>> removed.
>> 
>> I don't have the context calls but I do have setjmp/longjmp so that is what I
>> am trying to use.
>> 
>> I will shout if it works out.
>> 
>> -Steve
> 


Re: [9fans] rsc's libtask on embedded

2015-07-09 Thread Joseph Stewart
One other thing that I've looked at but never used is Adam Dunkels'
"protothreads" (http://dunkels.com/adam/pt/) although you'd still need to
roll your own channel library.

On Thu, Jul 9, 2015 at 10:50 AM, Steve Simon  wrote:

> The system I am trying to add libtask to has no runtime other than libc.
>
> Corrently it is an even based system that uses a "min main loop" and
> a twisty maze of nested state machines that all look the same.
>
> Hence my desire to add co-routines + channels (i.e. exactly what libtask
> is)
> to it. I have no need for the file or network modules but those are easily
> removed.
>
> I don't have the context calls but I do have setjmp/longjmp so that is
> what I
> am trying to use.
>
> I will shout if it works out.
>
> -Steve
>
>


Re: [9fans] rsc's libtask on embedded

2015-07-09 Thread Joseph Stewart
BTW, somewhere I "wired in" TADNS (http://adns.sourceforge.net/) so
libtask's network lookups didn't block.

Let me know if you have any interest in me cleaning it up for use.

-joe

On Thu, Jul 9, 2015 at 11:09 AM, David du Colombier <0in...@gmail.com>
wrote:

> Russ implemented his own setmcontext and getmcontext functions
> to work on systems that doesn't properly support ucontext.
> So I don't think you really need ucontext support in your libc.
>
> By the way, I maintain an updated version of libtask:
>
> https://github.com/0intro/libtask
>
> I've used it on quite a few places over the years,
> but I only on POSIX systems so far.
>
> --
> David du Colombier
>
>


Re: [9fans] rsc's libtask on embedded

2015-07-09 Thread Joseph Stewart
David, it's good to hear you're keeping libtask updated... I'll check it
out for sure!

On Thu, Jul 9, 2015 at 11:09 AM, David du Colombier <0in...@gmail.com>
wrote:

> Russ implemented his own setmcontext and getmcontext functions
> to work on systems that doesn't properly support ucontext.
> So I don't think you really need ucontext support in your libc.
>
> By the way, I maintain an updated version of libtask:
>
> https://github.com/0intro/libtask
>
> I've used it on quite a few places over the years,
> but I only on POSIX systems so far.
>
> --
> David du Colombier
>
>


Re: [9fans] rsc's libtask on embedded

2015-07-09 Thread Bakul Shah
Sounds like all you want are coroutines (with create, destroy & switch-to 
calls) and wait queues (with create, destroy, signal & wait calls). With these 
you can build channels easily. With a bit more work you can even implement 
pre-emption but then you need mutexes. Setjmp/longjmp is fine (that was I did 
in my first version ages ago!).

> On Jul 9, 2015, at 7:50 AM, Steve Simon  wrote:
> 
> The system I am trying to add libtask to has no runtime other than libc.
> 
> Corrently it is an even based system that uses a "min main loop" and
> a twisty maze of nested state machines that all look the same.
> 
> Hence my desire to add co-routines + channels (i.e. exactly what libtask is)
> to it. I have no need for the file or network modules but those are easily 
> removed.
> 
> I don't have the context calls but I do have setjmp/longjmp so that is what I
> am trying to use.
> 
> I will shout if it works out.
> 
> -Steve
> 



Re: [9fans] rsc's libtask on embedded

2015-07-09 Thread David du Colombier
Russ implemented his own setmcontext and getmcontext functions
to work on systems that doesn't properly support ucontext.
So I don't think you really need ucontext support in your libc.

By the way, I maintain an updated version of libtask:

https://github.com/0intro/libtask

I've used it on quite a few places over the years,
but I only on POSIX systems so far.

-- 
David du Colombier



Re: [9fans] rsc's libtask on embedded

2015-07-09 Thread Steve Simon
The system I am trying to add libtask to has no runtime other than libc.

Corrently it is an even based system that uses a "min main loop" and
a twisty maze of nested state machines that all look the same.

Hence my desire to add co-routines + channels (i.e. exactly what libtask is)
to it. I have no need for the file or network modules but those are easily 
removed.

I don't have the context calls but I do have setjmp/longjmp so that is what I
am trying to use.

I will shout if it works out.

-Steve



Re: [9fans] rsc's libtask on embedded

2015-07-09 Thread Joseph Stewart
I really like rsc's libtask and have managed to hide it in a few products.

As for your question: What architecture? Any runtime available?

Personally, I've used libtask on ARM/x86 under Linux/OSX... hardly "bare
metal" though.

The current implementation depends mostly on the ucontext API + berkeley
sockets for net stuff.

There's another project called http://libmill.org/ that is (was?) based on
setjmp/etc that might be easier to port.

Do keep me posted on your "travels"... I'm interested in this kind of stuff
too.

...or maybe we should just all help Charles updating/minimizing Inferno...

-joe

On Thu, Jul 9, 2015 at 4:38 AM, Steve Simon  wrote:

> Anyone stripped rsc's libtask for use on a bare metal embedded system,
> I'am about to do it but if somone already has I could steal it.
>
> -Steve
>
>


[9fans] rsc's libtask on embedded

2015-07-09 Thread Steve Simon
Anyone stripped rsc's libtask for use on a bare metal embedded system,
I'am about to do it but if somone already has I could steal it.

-Steve