[Tutor] threading vs. forking?

Thomas CLive Richards thomi@thomi.imail.net.nz
Thu Jul 10 04:35:01 2003


Hi,

I'm *trying* to develop a program which (amongst other things) reads
information from a serial port and prints it in a nice GUI interface.

The problem i have is that i don't know when data is going to be sent to
the port, so i have to use a polling method to fetch the data. The
problem with that is that while the program is polling the serial port,
the GUI isn't getting updated. 

So, AFAIK, there are two methods around this. there are probably many
more ways to do this, but i haven't a clue what they are.

The first would be forking the process using os.fork(), and running the
serial port polling in one fork, and the GUI in another, and somehow
send the data to the GUI.

the other would be using threading. The problem with that is that I've
never done it before, and from reading the documentation, I can't see
how to get information from one thread to another. There is likely to be
a lot of information on the port, so the information passing would have
to be easy...

so, what are the differences between forking and threading? why would
you use one, and not the other?

thanks,



-- 

Thomi Richards,
thomi@thomi.imail.net.nz