Parallel Programming??

Hello all,
I am new to C++ programming. I have encountered a problem where in i am supposed to run a counter when the program reaches a particular point and after that the counter just runs parallely to my program and sends interupts when it expires.. How do I implement the parallel thingy.. Any hints will be appreciated.
I think you might mean threads.
http://math.arizona.edu/~swig/documentation/pthreads/#whatare
Which operating systems do you need to compile with?
Depending on the OS and framework you can:

1) configure a periodic timer using library facilities (e.g. boost.asio). Increment the counter in the callback function that you provide.

2) launch a thread that runs a loop consisting of a sleep_for() call and a counter increment.

3) configure an periodic timer using OS facilities (e.g. POSIX has it) and increment your counter in the timer signal handler

there's probably more.. you said "new to C++", but is it new to asynchronous calls and interthread synchronization as well? If you are, then maybe it's better to do
4) check the current time directly in the code wherever it could potentially be interrupted by the counter.
I will compile in ubuntu. Can u suggest a library which will have multithreading and which is commonly available. I mean since I have to submit the code some where and if I have a very uncommon library which they might not even have hence the worry.
Thanx
ubuntu has fairly modern C++ compilers which support threads natively.

To support legacy compilers, you could use the boost library, it doesn't get more common than that.
If you are just compiling on linux, you should try pthread http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html
i dont understand the difference between threads and processess. How do we decide which one to select for a particular process?
A process is an instance of an executing program.

A thread is part of a process. A single process (i.e. any one program that is running) can contain many threads.
Topic archived. No new replies allowed.