On Sat, Oct 26, 2002 at 03:58:55AM -0500, Richard R. Sivernell wrote:
> List C++ programmers or Kurt or David B.
> 
> - Writing a small program for a college course and almost there. Using
> c++, I am using a an object called Agent, & it must travel a torus, that a 
> gride of x by y. When you get to an end, you jump to the other end. Its
> a math thingy, All is working well except I need to write to a log file every
> 60 seconds the number of moves the object has performed. I have created 
> a timer object, but executing 2 ques at once in Linux I do not know. My

I don't understand what you mean. Executing 2 whats?

> question is an alarm the really only way to do this and it call a callback
> function or is there a better way. At this time I do not want to put this 
> in a thread unless that is the only way.  Any suggestions are welcomed here.

No, you don't have to use an alarm, or rather, the alarm() system call.
You can use setitimer(), set it to go off every 60 seconds, at which
point it generates a signal (SIGALRM, SIGVTALR, or SIGPROF). Set up a
signal handler for this signal and have the handler scribble in the log
file. You'll need a way to communicate the number of moves to the handler,
but, becuase this is for a course, I'll leave this as an assignment for
the reader. ;-)

>   Kurt you Linux Programming book has been nothing short of real blessing 
> since I bought it, thanks. I have put the Message Que into a class and it works 
> great, using the info from your book. The other Linux Programming book by 
> Stones and Matthew is OK, justnot the quality of your.

Thanks, Rick. I'm glad you found it useful.

Kurt
-- 
Politicians are the same all over.  They promise to build a bridge even
where there is no river.
        -- Nikita Khrushchev
_______________________________________________
Linux-users mailing list
[EMAIL PROTECTED]
Unsubscribe/Suspend/Etc -> http://www.linux-sxs.org/mailman/listinfo/linux-users

Reply via email to