Hi,
Having multiple threads in an application is not that difficult using a
modified event loop. We don't really need help from the OS for that
(although OS services for waiting for a signal or event is helpful for
power consumption, compared to active polling/looping).
The most difficult task is multiple processes... having a task running
(ex dealing with a network connection) while another application is
running (an internal app like the agenda). That's the challenge with
PalmOS!
Jerome
Jeremy Brown wrote:
Hi,
Everybody in here has seen a million requests, "How can I use threads", and a million
responses, "You can't".
Well, I saw this posted on Slashdot and I thought it might be useful to someone.
From the Protothreads site:
[quote]
Protothreads are extremely lightweight stackless threads designed for severely
memory constrained systems, such as small embedded systems or wireless sensor
network nodes. Protothreads provide linear code execution for event-driven
systems implemented in C. Protothreads can be used with or without an
underlying operating system.
Protothreads provide a blocking context on top of an event-driven system, without the overhead of per-thread stacks. The purpose of protothreads is to implement sequential flow of control without complex state machines or full multi-threading.
While protothreads originally were created for memory-constrained embedded systems, it has found many uses as a general purpose library too. Examples include multimedia streaming server software, grid computing research software, and MPEG decoding software for Internet TVs.
[/quote]
Anyways, the source is distributed using an "open source BSD-style" license, in
ANSI C, without any assumptions made of the underlying system. I haven't made any
attempt to understand it, but I don't need to use threads either. But I offer it for the
benefit of everyone who doesn't read Slashdot.
Protothreads: http://www.sics.se/~adam/pt/
Slashdot Article:
http://it.slashdot.org/article.pl?sid=05/10/06/2223232&from=rss
Jeremy
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/