Search the web
Sign In
New User? Sign Up
cheapthreads · cheap_threads
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
hi all its roshan   Message List  
Reply | Forward Message #55 of 89 |
Re: [cheapthreads] hi all its roshan

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




Fri Jul 22, 2005 5:41 pm

jm407a
Offline Offline
Send Email Send Email

Forward
Message #55 of 89 |
Expand Messages Author Sort by Date

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...
dol_roshan
Offline Send Email
Jul 22, 2005
7:52 am

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 ...
Scott McKellar
jm407a
Offline Send Email
Jul 22, 2005
5:41 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help