Questions about timer in multi-threads environment


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Programming Questions about timer in multi-threads environment
# 1  
Question Questions about timer in multi-threads environment

Hi

I have questions about timer function in multi-threads environment.

My application has multi-threads, in one thread, I set a timer, when the timer expires, the timer function will interrupt other thread and execute.

I am not clear which thread will be interrupted by the timer function ?
Does the thread in which I set the timer be interrupted, or it depends on OS.

If my application is running on one CPU machine, I think the current thread will be interrupted. If the application is running on mult-CPU machine, and SMP is on, which thread will be interrupted.

If the thread I set the timer has finished and gone, when timer expires, what will happen ? Smilie


thanks & regards
Jeffrey
06-07-04
# 2  
Open source is life savor

See the page
WebSVN - packet-o-matic - Rev 157 - -trunk-src-timers.c

https://svn.tuxicoman.be/filedetails...Ftimers.c&sc=1

Both timer.c and timer.h is complete implementation
# 3  
Quote:
Originally Posted by longskys
My application has multi-threads, in one thread, I set a timer, when the timer expires, the timer function will interrupt other thread and execute.

(a) what mechanism are you using for timers?

(b) what do you mean by interrupt?

I do hope you are using "pthread_cond_timedwait". From what you say I would suggest you don't need a separate timer thread, you have "other thread" wait on "pthread_cond_timedwait".
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #319
Difficulty: Medium
The open source program Redis is a relational database server.
True or False?

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to substract selective values in multi row, multi column file (using awk or sed?)

Hi, I have a problem where I need to make this input: nameRow1a,text1a,text2a,floatValue1a,FloatValue2a,...,floatValue140a nameRow1b,text1b,text2b,floatValue1b,FloatValue2b,...,floatValue140b look like this output: nameRow1a,text1b,text2a,(floatValue1a - floatValue1b),(floatValue2a -... (4 Replies)
Discussion started by: nricardo
4 Replies

2. Programming

Deallocating memory in multi-threaded environment.

I'm having a hard time figuring out how to manage deallocation of memory in multithreaded environments. Specifically what I'm having a hard time with is using a lock to protect a structure, but when it's time to free the structure, you have to unlock the lock to destroy the lock itself. Which will... (5 Replies)
Discussion started by: gngrwzrd
5 Replies

3. Programming

In unix how we can test or check race condition in a c program by using multi threads

In unix how we can test or check race condition in any c program by using multi thread programming (1 Reply)
Discussion started by: afroze
1 Replies

4. Programming

In unix how we can test or check race condition in c program by using multi threads

In unix how we can test or check race condition in any c program by using multi thread programming (5 Replies)
Discussion started by: afroze
5 Replies

5. UNIX for Dummies Questions & Answers

In unix how we can test or check race condition in a c program by using multi threads

In unix how we can test or check race condition in any c program by using multi thread programming (1 Reply)
Discussion started by: afroze
1 Replies

6. Linux

In unix how we can test or check race condition in c program by using multi threads

In unix how we can test or check race condition in any c program by using multi thread programming (1 Reply)
Discussion started by: afroze
1 Replies

7. Programming

Multi-threading-- calling same function through different threads

Sir, Can I call same function in the start routines of different Threads. I have created two different threads....and wanna call same function from both threads....is it possible??? Also can I fork inside a thread??? (1 Reply)
Discussion started by: arunchaudhary19
1 Replies

8. Programming

Multi-threading questions

I've been doing some reading lately about threading (Posix threads) and I'm really curious about a couple things that I've read. I'm not sure if many people here have threading experience, but I thought it would be nice to be able to discuss some questions about it. (For the record, I did... (1 Reply)
Discussion started by: DreamWarrior
1 Replies

Featured Tech Videos