LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   c++ simultaneous funtions? (http://www.linuxquestions.org/questions/programming-9/c-simultaneous-funtions-385560/)

Ha1f 11-22-2005 02:22 PM

c++ simultaneous funtions?
 
Hi,

Im still learning to program and I have a question about using funtions simultaneously in a program. Mainly I want to know if its possible...and if it is...how to do it.

Lets say I have functions funca(),funcb(), and funcc(). Could my program make them all run at the same time? I dont want to call them in order, I want them to run on parrallel to each other.

nadroj 11-22-2005 02:34 PM

is it _really_ necessary that you need this for an intro to c++ program?
but yes it is most definetly possible.. you use threads/processes.
its called 'multi-threaded development' i believe
(sorry no examples)

Ha1f 11-22-2005 04:19 PM

im not in a class or anything, im learning on my own right now. im past the intro phase, just wanted to know if this was possible.

thanks!

nadroj 11-22-2005 04:29 PM

ok :)
keep up your research then! gj

im sure you have already checked it out but.. this site is a very helpful resource. (doesnt talk about threads etc; just an overall good resource though)

Dark_Helmet 11-22-2005 04:35 PM

Just throwing this out there...

Yes, threading can make two or more threads active simultaneously. However, unless the program is run on a multi-processor system, only one thread (and hence, one function) will receive processor attention at any particular moment in time. In other words, one processor cannot perform two sets of instructions in the same time slot.

nadroj 11-22-2005 04:39 PM

good point.

multi-threaded apps work on any architecture (well.. no.. i think all Apple, *Nix, and M$ 95+).. but to take advantage of the 2-things-at-once, must have multiple CPUS (or hyperthreading, or hyper transport cpu)

GUI's for example.. every gui (that is interactive) is multi threaded. there are threads for listening for events (ie button clicks etc) and for displaying windows or for controlling the interactions.

Ha1f 11-22-2005 06:04 PM

this is great! its exactly the kind of stuff i wanted to know about!

thanks again guys!


All times are GMT -5. The time now is 09:05 AM.