Questions tagged [setitimer]

29 questions
1
vote
1 answer

Signal Handler not invoked when sigaction is used

I am trying to implement a user level thread library and need to schedule threads in a round robin fashion. I am currently trying to make switching work for 2 threads that I have created using makecontext, getcontext and swapcontext. setitimer with…
1
vote
1 answer

setitimer and signal count on Linux. Is signal count directly proportional to run time?

There is a test program to work with setitimer on Linux (kernel 2.6; HZ=100). It sets various itimers to send signal every 10 ms (actually it is set as 9ms, but the timeslice is 10 ms). Then program runs for some fixed time (e.g. 30 sec) and counts…
osgx
  • 90,338
  • 53
  • 357
  • 513
0
votes
0 answers

Fast low resolution clock based on interval signal timer

I need a fast and portable low resolution (~10 ms) clock to implement timeouts in a high-rps app. Even using clock_gettime results in an unacceptable reduction in rps. I decided to create my own low-resolution clock based on setitimer with 10 ms…
drew
  • 21
  • 1
0
votes
1 answer

How to use setitimer with SIGALRM in C

I'm trying to use setitimer to send out a SIGALRM, which in turns calls my handler function to print to stdout. I've been scouring the internet for hours now and there is simply no clear indication on how setitimer should be used. I've tried various…
Devin M
  • 5
  • 1
  • 4
0
votes
2 answers

Interval Timer not firing signal at specified time interval

I want to call timer_handler function at every 2 seconds regardless of execution time of timer_handler function here is my code #include #include #include #include #include void timer_handler…
Krunal Sonparate
  • 1,122
  • 10
  • 29
0
votes
1 answer

How to have signal handler print time elapsed?

I am writing a C program that has a sigaction handler. It also has a itimerval in case SIGALRM doesn't come in a while. The handler should print the total number of infinite loop completed print the time elapsed exit(1); I noticed that signal…
Sara Takaya
  • 298
  • 2
  • 17
0
votes
1 answer

reacting to two signals sent to the CPU in linux

I wrote the following code: void handler (int signal) { if (signal==SIGVTALRM) { printf("one second passed\n"); } if (signal==SIGALRM) { alarm(1); //printf("curret context is %ld\n" , thread_tbl[currThreadNum].uc.uc_mcontext.cr2); …
CrazySynthax
  • 13,662
  • 34
  • 99
  • 183
0
votes
2 answers

c setitimer not sending signal when outside its call scope

i have the following case void foo() { printf("hi\n"); while(1); } int main(void) { struct sigaction temp; temp.sa_handler = &foo; sigfillset(&temp.sa_mask); sigdelset(&temp.sa_mask, SIGVTALRM); sigdelset(&temp.sa_mask, SIGINT…
user2717954
  • 1,822
  • 2
  • 17
  • 28
0
votes
1 answer

Why do setitimer and dup2 work for a child proccess after execvp?

First let me say that there are a lot of questions in here. One of the tasks for my thesis requires me to write a program that executes a sub-program and kills it if it running time ( not wall-time but user+sys ) is more then a specific value or…
Ext
  • 657
  • 1
  • 8
  • 13
0
votes
1 answer

Code not making using of more than one signal handler

I have this code that I want to use to handle different signals. I don't know why it never goes to timer_handler2(). It just sticks on timer_handler(). Could someone kindly tell me what I am doing wrong #include #include…
Yanki Twizzy
  • 7,771
  • 8
  • 41
  • 68
0
votes
1 answer

Properly configuring signal.setitimer()

I'm having a bad time figuring why the program is pausing indefinitely, i.e. exhibiting infinite-loop-like behavior def class foo(): ''' ... ''' def __catcher(self, signum, _): print "TIME OUT EXCEEDED" # Reset timer …
ToniAz
  • 430
  • 1
  • 6
  • 24
0
votes
1 answer

C signal handling with timer

http://codepad.org/rHIKj7Cd (not the whole code) What I'm trying to accomplish, is the parent to write something in the shared memory, then the child to react accordingly, and write something back, every five seconds. I thought about using…
Innkeeper
  • 663
  • 1
  • 10
  • 22
0
votes
1 answer

How to schedule simultaneously two functions at random intervals using itermerval and sigaction structures C++

Here the new code snippet: #define SIMU_TIME 30 pthread_mutex_t mymutex = PTHREAD_MUTEX_INITIALIZER ; pthread_cond_t condition = PTHREAD_COND_INITIALIZER ; void *timer(void *Ptr) { while ((float) clock()/CLOCKS_PRE_TICKS < SIMU_TIME) …
Galileo
  • 321
  • 1
  • 4
  • 12
0
votes
1 answer

How to schedule simultaneously two events using sigaction and itimerval structures in C++ ?

I would like to schedule an event in a specific time, more precisely, I want to generate a poisson traffic. So I need to send a packet at specific time intervals that are generated from an exponential distribution. I have done some researches on the…
Galileo
  • 321
  • 1
  • 4
  • 12
1
2