LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-22-2005, 02:22 PM   #1
Ha1f
Member
 
Registered: Jun 2005
Location: University of Maryland
Distribution: FreeBSD
Posts: 268

Rep: Reputation: 30
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.
 
Old 11-22-2005, 02:34 PM   #2
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
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)
 
Old 11-22-2005, 04:19 PM   #3
Ha1f
Member
 
Registered: Jun 2005
Location: University of Maryland
Distribution: FreeBSD
Posts: 268

Original Poster
Rep: Reputation: 30
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!
 
Old 11-22-2005, 04:29 PM   #4
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
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)
 
Old 11-22-2005, 04:35 PM   #5
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
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.
 
Old 11-22-2005, 04:39 PM   #6
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
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.
 
Old 11-22-2005, 06:04 PM   #7
Ha1f
Member
 
Registered: Jun 2005
Location: University of Maryland
Distribution: FreeBSD
Posts: 268

Original Poster
Rep: Reputation: 30
this is great! its exactly the kind of stuff i wanted to know about!

thanks again guys!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Anyone who used acl.h funtions? kcv SUSE / openSUSE 0 10-13-2005 07:09 PM
Simultaneous X sessions 64 Bit Headache Linux - General 1 02-12-2005 03:04 PM
two simultaneous gateways pe2338 Linux - Networking 1 06-04-2004 10:25 AM
Simultaneous CD Burning onu Red Hat 9 01-26-2004 02:38 PM
emacs? - how to get help with c++ or c funtions in it? breadbin Linux - Software 1 06-28-2003 06:03 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration