Linked by Thom Holwerda on Sun 18th Jan 2009 11:16 UTC, submitted by anonymous
General Unix Protothreads are a type of extremely lightweight threads - each protothread requires only two bytes of memory - that are usually used for embedded firmware programming, where memory is at a premium. Protothreads combine the low overhead with event-driven programming with the algorithmic clarity of threaded programming.
Thread beginning with comment 344256
To view parent comment, click here.
To read all comments associated with this story, please click here.
Member since:

and my first guess are embedded systems on top of Linux kernel? I mean - come on, ordinary threads are lightweight enough for modern hardware. But threads on my phone definitely coud be lighter ;) .

Ordinary threads are pretty heavyweight, if there are thousands of them. E.g. think of running a simulation of 10000 objects, each object in its own thread. That would hog up the kernel pretty badly - while having all threads within one kernel thread neatly compartmentalizes the scheduling to that one thread.

Of course this is not a case where you would typically use threads, but at least it's possible. Though the applications are more ofter of scientific rather than practical interest.

Reply Parent Score: 1

PlatformAgnostic Member since:

Threads which are blocked should not consume any computational reasources... only memory, so if you use threads only as a means of specifying your algorithm and you don't have too many running concurrently, 10,000 threads should only increase your memory footprint and startup time without affecting runtime performance.

Reply Parent Score: 2

vivainio Member since:

Threads which are blocked should not consume any computational reasources...

But consider the situations where the threads are NOT blocked. If you have 5000 threads that are unblocked, you have 5000 context switches to do (and context switches are not free).

Reply Parent Score: 1