1 Replies - 116 Views - Last Post: 07 February 2012 - 05:01 AM Rate Topic: -----

Topic Sponsor:

#1 znerihc  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 52
  • Joined: 05-February 12

Simultaneous processes in c++?

Posted 07 February 2012 - 04:35 AM

Good day! I am just wondering if it is possible to have simultaneous processes in a c++ console application. I am just beginning to learn the language and I noticed everything seems pretty linear. By linear I mean, after a process is over, the next one executes, so on and so forth. What I want to know if it is possible to have two processes at one time, or at least a pseudo way of achieving that.

For example, a timer counts down while some process is being done, and the time ending will serve as the reason for why that certain process terminates.

I really want to do that? What topics in c++ should I read about?

Is This A Good Question/Topic? 0
  • +

Replies To: Simultaneous processes in c++?

#2 Karel-Lodewijk  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 438
  • View blog
  • Posts: 849
  • Joined: 17-March 11

Re: Simultaneous processes in c++?

Posted 07 February 2012 - 05:01 AM

You can create other processes from C/C++, but what you most likely want is threads. Hardware threads will allow you to have multiple paths of execution in the same program which can run in parallel on different processors.

C/C++ doesn't come with native support for threads, you need a library to use them. The major thread libraries are windows threads for windows, posix threads or pthreads for mac/linux. But I would recommend Boost::thread, it will use windows threads on windows and pthreads on max/linux and boost comes with a lot of other features that can be useful in your program.

That being said, programming multi-thread applications does come with it's share difficulties, read up a little about the topic first.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1