Live data from Hacker News

Show HN: uThreads – Concurrent User Threads in C and C++

samanbarghi.com

11–20 of 64 posts

Re: Show HN: uThreads – Concurrent User Threads in C and C++

#11
post #4

Interesting, I've recently been looking for a user level threading package in C/C++. I ended up settling on lthreads: http://lthread.readthedocs.io/en/latest/intro.html Does anyone know how it compares?

Hi, I developed uThreads. I looked at lthreads quickly, and it seems lthreads only maps multiple coroutines onto a single pthread (N:1). Although, it adds the possibility of running multiple pthreads, but each pthread can only run their local lthreads (using M threads that do N:1 mapping). However, in uThreads, uThreads can be multiplexed over multiple pthreads (thus M:N mapping). Also lthreads scheduler is based on…

I recommend trying to get access to larger machines with more hardware parallelism. I have seen techniques that scale just fine to using 16 threads, but hit serious limitations when you get to over 100 threads.

Re: Show HN: uThreads – Concurrent User Threads in C and C++

#12
post #7

Earlier quoted context omitted.

Thanks! good point; now that I look at the page, there is not a single sample code in there. I'll update it soon.

Awesome! As an example, Rayon[0] does a very good job (IMHO) at this. [0] - https://github.com/nikomatsakis/rayon

Thanks, oh all those fancy functions. I need to improve the interface a bit, as for now everything is only based on using uThreads as the unit of concurrency. e.g., this is a recursive Fibonacci: https://github.com/samanbarghi/uThreads/blob/master/test/Fib... and a fork-and-join Fibonacci: https://github.com/samanbarghi/uThreads/blob/master/test/Fib...

There is no fork-and-join in uThreads yet, and I created it using create and join. The interface will improve in the future :)

Re: Show HN: uThreads – Concurrent User Threads in C and C++

#14
post #10

Impressive. 8KiB stacks are a bit on the small side though for production usage. Go gets away with this because they're stacks act more like Vectors then flat arrays. Why did you decided to roll your own stack swapping software instead of using say using `boost::context`?

Right, however segmented stacks are have high overhead and stack copying is not very easy in C/C++. Thus, for now uThreads only support fixed size stacks, I know it makes it harder to be used in production, and in the future I might provide optional segmented stacks. As for why not using `boost::context`, I am implementing uThreads as part of my research in uwaterloo, I wanted to have full control over the code and b…

and yet you're relying on a compiler and linked libraries you didn't write.

you're all idiots.

Re: Show HN: uThreads – Concurrent User Threads in C and C++

#15
post #13

Is there any reason you chose GPL3 or would you consider a less restrictive license like Apache or BSD?

Can we please stop calling out nearly every project that uses GPL (3) and call it restrictive? I know there are different opinions and arguing which is "better" nearly always leads to a philosophical debate on principles that gets us nowhere.

Sorry if this sounds snarky, and I do not blame you in particular, but it is just a theme I have encountered here the last years that I find toxic as it portrays the GPL (and FSF) as some evil organization that would restrict "developer's rights".

Re: Show HN: uThreads – Concurrent User Threads in C and C++

#16
post #13

Is there any reason you chose GPL3 or would you consider a less restrictive license like Apache or BSD?

Can we please stop calling out nearly every project that uses GPL (3) and call it restrictive? I know there are different opinions and arguing which is "better" nearly always leads to a philosophical debate on principles that gets us nowhere. Sorry if this sounds snarky, and I do not blame you in particular, but it is just a theme I have encountered here the last years that I find toxic as it portrays the GPL (and FS…

Not sure what the OP's motivation are for asking "why GPL?", but my motivation when I ask that can translate to something like this:

"Hi, I'd like to use your library, but your license is incompatible with the other licenses in my codebase. Consider BSD please?"

Re: Show HN: uThreads – Concurrent User Threads in C and C++

#19

This looks super interesting! I've been working on a Raytracer in C++ and I was recently looking into a threading library which I can use to parallelize the rendering. Surely going to try this out in the coming weekend. Unsolicited suggestion - while benchmarks and the motivation are important for a threading library, a code snippet of a simple parallel program on the home page would be something that I'd love to see…

Isn't raytracing almost completely CPU-bound? Seems like a odd use-case for green threads, which afaik are more commonly used for IO-bound tasks.

Re: Show HN: uThreads – Concurrent User Threads in C and C++

#20

Earlier quoted context omitted.

Can we please stop calling out nearly every project that uses GPL (3) and call it restrictive? I know there are different opinions and arguing which is "better" nearly always leads to a philosophical debate on principles that gets us nowhere. Sorry if this sounds snarky, and I do not blame you in particular, but it is just a theme I have encountered here the last years that I find toxic as it portrays the GPL (and FS…

Not sure what the OP's motivation are for asking "why GPL?", but my motivation when I ask that can translate to something like this: "Hi, I'd like to use your library, but your license is incompatible with the other licenses in my codebase. Consider BSD please?"

It's not like GPL v3 prevents guy from contacting the author and offering him $ for license.
Post reply on HN