Depending on how you write to the serial port, Cheap
Threads probably won't help you. The Cheap Threads
web site mentions this point on the Pros and Cons
page.
In order to use Cheap Threads to do IO concurrently
with other processing, you need some form of
non-blocking IO. Most forms of IO, however, are
blocking.
For example, if you call the standard C function
fwrite(), it doesn't return control to the calling
program until it is finished. If you call fwrite()
from within a Cheap Thread, that thread can't continue
until fwrite() returns, and neither can any other
thread. Control switches from one thread to the next
only when the first thread gives up control, and it
can't do that when it's waiting for fwrite() to
finish.
With non-blocking IO you would call some special
function that would return immediately without having
actually done any IO yet. Then your code could do
whatever it wants to do while something in the OS, or
in the hardware, did the IO in the background. You
would also have some way of finding out later whether
the IO had completed, and whether it had been
successful.
Non-blocking IO is not very common unless you are
working at a very low level, with device drivers or
disk controllers or something. I've never done it
myself. There are two main ways to fake it:
1. Use true multithreading, as with Pthreads or Java.
2. Spawn a separate process to do the IO, and use some
form of interprocess communication to pass the data
back and forth, such as sockets or a shared memory
segment.
The choice between these two methods depends in part
on the environment. In UNIX and Linux it's probably
more common to spawn a separate process. In Windows,
where there's more overhead involved in spawning a
process, you may prefer to use some form of true
multithreading.
Scott McKellar mck9@...
http://home.swbell.net/mck9/ct/
--- dol_roshan <dol_roshan@...> wrote:
> im a student
> im new to this library
> i need help to run multi tasking in C
> i need to process the data and simultaniously send
> it through serial
> port through a queue
> plz help me to use this library
>
> roshan