Click to See Complete Forum and Search --> : Threads in ANSI C ?
Ferdinando
May 8th, 2004, 08:22 AM
Hi group,
actually I create an ANSI C program running on external hardware with ANSI C compiler. This hardware has got a RS232-Port.
I created the main-program (collecting data) and it runs fine.
But now I have to communicate via RS232 with a "normal" PC to send and receive data collected "offline" by this external hardware.
First step is to make a "thread" informing me, when the PC is connected via RS232.
Next step is to let the main-program sleep and start data-transfering with PC.
Last step is to reactivate the main-program until the RS232-Port is connected again.
And so on...
My question is: how can I implement MultiThreading in ANSI C?
I have done it in JAVA before, but I can not find any hints for ANSI C :cry:
Any hints like mini-demo-program, URLīs, books, basic knowlegde are very welcome.
Thanks in advance,
Ferdinando
kuphryn
May 8th, 2004, 10:43 AM
What OS is this external hardware running? Is it a UNIX based OS? If yes, check out POSIX.
Kuphryn
Ferdinando
May 8th, 2004, 10:57 AM
Originally posted by kuphryn
What OS is this external hardware running? Is it a UNIX based OS? If yes, check out POSIX.no, depending on Hardware-Release most are running with DOS6.x
kuphryn
May 8th, 2004, 11:08 AM
No. DOS does not support multithreading.
Kuphryn
Ferdinando
May 8th, 2004, 11:29 AM
Originally posted by kuphryn
No. DOS does not support multithreading.
ARGGGH !!!
but thanks a lot for your answere.
Ferdinando
wien
May 8th, 2004, 07:57 PM
Originally posted by Ferdinando
...
First step is to make a "thread" informing me, when the PC is connected via RS232.
Next step is to let the main-program sleep and start data-transfering with PC.
Last step is to reactivate the main-program until the RS232-Port is connected again.
And so on...
...Since you plan to put the main thread to sleep while transferring data anyway, it shouldn't be too much of a hazzle to implement this in a single-threaded enviroment.
This is pure guesswork from my side, but it sounds as if you could simply check if the PC is connected at some interval, and if it is, call a function that handles the transfering of data.
Just a thought..
Ferdinando
May 9th, 2004, 05:12 AM
Originally posted by wien
Since you plan to put the main thread to sleep while transferring data anyway, it shouldn't be too much of a hazzle to implement this in a single-threaded enviroment.Nothing else remaines, if multithreads are not possible...
In single Thread the RS232-part can only be called "between" other program-parts and itīs not "live".
The problem is, that the main-routine waits for an user-input.
If the user does nothing, the program is not able to recognize, that the RS232 is plugged.
Mathew Joy
May 10th, 2004, 02:14 AM
DOS does not support Multi threading. But it supports "crude" form of multitasking. You can do multitasking to some extend, without using threads, by creating TSRs. You can program the TSR to respond to some "events" and unload it as soon as the program is over.
Ferdinando
May 10th, 2004, 04:58 AM
Helo Mathew,
Originally posted by Mathew Joy
DOS does not support Multi threading. But it supports "crude" form of multitasking. You can do multitasking to some extend, without using threads, by creating TSRs. You can program the TSR to respond to some "events" and unload it as soon as the program is over. Where can I get help with TSR? Do you have any URL or documentation-hints for me?
Thanks a lot,
Ferdinando
Mathew Joy
May 10th, 2004, 05:21 AM
Originally posted by Ferdinando
Helo Mathew,
Where can I get help with TSR? Do you have any URL or documentation-hints for me?
Thanks a lot,
Ferdinando Sorry, I learned these stuff from books. Since TSRs don't work in windows, it is almost extinct today. You can try googling and see if there is any materials on the web. TSRs use functions such as keep() getvect() setvect() etc.
Ferdinando
May 10th, 2004, 05:36 AM
Originally posted by Mathew Joy
You can try googling and see if there is any materials on the web. TSRs use functions such as keep() getvect() setvect() etc. Superb, thanks a lot!
Ferdinando
Codeplug
May 20th, 2004, 07:17 PM
I found a potential alternative this with some good links (if you're using a GNU compiler).
http://home.hccnet.nl/kees.moerman/c_clwp_e.html
gg
codeguru.com
Copyright 2007 Jupitermedia Corporation All Rights Reserved.