halayli / lthread

lthread, a multicore enabled coroutine library written in C
Other
814 stars 82 forks source link

lthread_sleep() bug? #28

Closed liexusong closed 10 years ago

liexusong commented 10 years ago

May be exists bug when call function lthread_sleep(0), because current CPU context was lose.

halayli commented 10 years ago

True. Thanks for raising the issue. What were you attempting to do with lthread_sleep(0) ?

liexusong commented 10 years ago

When I read the source codes and found it, may be solved this problem by codes:

void
lthread_sleep(uint64_t msecs)
{
    struct lthread *lt = lthread_get_sched()->current_lthread;

    if (msecs <= 0) {
        return;
    }

    _lthread_sched_sleep(lt, msecs);
}
JunfengJia commented 10 years ago

Any preferred api to yield current coroutine?

halayli commented 10 years ago

lthread_sleep(1);

What's the reason behind the yield?

JunfengJia commented 10 years ago

thread ring benchmark, I'm evaluate the performance.

lthread_sleep(1) will hurt it.

if (msecs == 0) { just put it into running list and switch would be good. }

Any arm support plan? the program I write will used x64 and arm in linux. Your lthread is the most well written and maintained one.

halayli commented 10 years ago

Ah perf bench.

Sure, won't hurt putting it in the running list.

While I don't have plans to support ARM, I don't mind supporting it. Will give it a shot on the weekend.

JunfengJia commented 10 years ago

thanks, that's great.

from bench, threadring is more quick than libtask.

halayli commented 10 years ago

Fixed. lthread_sleep(0) causes the lthread to yield only.

jannson commented 8 years ago

@JunfengJia can you try this fork for arm? https://github.com/jannson/lthread

I have just support it for some days and test ok. But I want more to test it.