Linked by Thom Holwerda on Mon 5th Jun 2006 18:15 UTC, submitted by Adam Dunkels
General Development Protothreads are an extremely lightweight, stackless, thread-like programming abstraction designed for severely memory constrained embedded systems that may have as little as a few hundred bytes of RAM. Protothreads are designed to replace event-driven C code with sequential programming but without the memory overhead of full multithreading - a protothread requires only two bytes of RAM. Protothreads are implemented in ANSI C, does not require any machine code, and is therefore highly portable. Version 1.3 adds the possibility to determine if a protothread is blocked, has yielded or has ended, and can be downloaded here. Also be sure to read how protothreads work, under the hood.
E-mail Print r 0   5 Comment(s)
Order by: Score:
preprocessor forever
by transputer_guy on Mon 5th Jun 2006 20:20 UTC
Member since:

I love how much can be done with the preprocessor something most of the newer Java users will never know.

It basically lets one reinvent a language to fit ones needs and also allows one to shoot themselves in the foot when it doesn't work. Portability though seems to be a killer, different preprocessors in compilers reduced my useage of it quite a bit.

Without __LINE__, I guess this thread package would be alot harder or impossible. I had only thought about using it in compiler error contexts but this makes me think more about other uses, and it brings us back to Contiki again.

Reply Score: 1

RE: preprocessor forever
by zlynx on Mon 5th Jun 2006 21:43 UTC in reply to "preprocessor forever"
zlynx Member since:

If you like preprocessor tricks in C, you should love LISP. Since the language is written in its own data structure, LISP macros are actual LISP programs that process and rewrite the rest of the program (or even themselves) during compilation.

Reply Score: 1

RE[2]: preprocessor forever
by transputer_guy on Tue 6th Jun 2006 02:12 UTC in reply to "RE: preprocessor forever"
transputer_guy Member since:

We are all doomed to reinvent Lisp in one way or another, though its much worse for those that don't know that.

While I wouldn't choose to write in Lisp today, I still on my most respected language list (of (lists)) and my other list of most unreadable. I was never a fan of Lambda calculus either.

I can live without self modifying (or even self constructing code on the fly) since caches & OoO cpus don't much like it but then a compiler in your project can give you some of that.

Reply Score: 1

by Cloudy on Mon 5th Jun 2006 21:42 UTC
Member since:

ala duff's device.

amusing. > 30 years old.

You can do it without __LINE__ but you get to have more fun if you do.

Reply Score: 1

Weird and dangerous !
by Kochise on Wed 7th Jun 2006 08:31 UTC
Member since:

The C language sadly allows various ways to write it, especially multiple instructions per line (this is NOT like assembler which allows only one instruction per line). My boss and some of my collegues have exactly this f--king habitude to write several things 'belonging to the same statement' on the same line. Now imagine multiple nested PT_WAIT_UNTIL on the same line... How the hell are you finding the bug ?


Reply Score: 1