Questions tagged [setitimer]

29 questions
5
votes
1 answer

setitimer question

I have the following code running on my dual core machine. When i'm running one or two instances of the application on the same PC, I have the correct timing resolution of 100msec. However, when i ran 3 instances of the same application on the same…
Ng Keng Leng
  • 51
  • 1
  • 3
4
votes
0 answers

Python: SIGALRM and setitimer in windows

The following code works in Unix, but i would like to transfer it to a Windows OS. The problem is that in Windows signal.SIGALRM and signal.setitimer don't work. I would really appriciate if someone could help me. def handler(signum, frame): …
EmbedEngineer
  • 93
  • 2
  • 7
3
votes
1 answer

Understanding struct itimerval field tv_usec

Hi I'm studying this code: #include #include #include #include #include #include #include volatile sig_atomic_t print_flag = true; static int count = 0; void…
Zeno Raiser
  • 207
  • 2
  • 10
3
votes
0 answers

How to set two timers both on cpu time and real time of a process?

I try to use setitimer(ITIMER_PROF, &tick, NULL) to limit the cpu time consuming by the process. But if the process turns to suspend (in my case ,the process sinks into a dead loop, then the Ubuntu16.04 suspends it and does not wake up it again),…
wangbo15
  • 191
  • 1
  • 13
3
votes
1 answer

Pausing a timer using setitimer?

In C, is there a way to start a timer using setitimer, then pause it, then resume the timer with the time remaining when it was paused? My initial thought was to save the time left by using getitimer, stop the timer, then set the timer back to the…
Anthony C.
  • 139
  • 1
  • 3
  • 7
2
votes
2 answers

Prevent SIGALRM from interrupting waitpid()

I'm trying to make my process waitpid() for a child process, but also print something every interval amount of time. My current plan is to schedule an itimer, waitpid(), handle the SIGALRM printing, and stopping the timer when the waitpid()…
Matt Goodrich
  • 4,875
  • 5
  • 25
  • 38
2
votes
0 answers

Using sigaction and setitimer system calls to implement assembly language timer on BSD/OS X

I'm trying to implement a timer routine in 32-bit assembler on OS X Lion using sigaction() & setitimer() system calls. The idea is to set a timer using setitimer() & then have the generated alarm signal invoke a handler function previously setup…
frijid
  • 21
  • 3
1
vote
1 answer

setitimer on linux rounding up?

When I set a short timeout with setitimer and then query the set value (with getitimer or another setitimer) on a Linux 2.6.26 system (Debian 5.0.5), I get back a value higher than I set: #include #include int main() { …
Christopher Creutzig
  • 8,656
  • 35
  • 45
1
vote
1 answer

Is setitimer() call inherited by children

I'm writing a code forking (number of 3, 5, ... indefinite number). I wish my program to end after the time specified(parent kills firstly its children then itself probably by calling _exit which is also sig-safe). I mean in signal handler I kill…
concurrencyboy
  • 351
  • 1
  • 11
1
vote
1 answer

What causes the virtual run time to go slow when using setitimer() and ITIMER_VIRTUAL?

In order to study the differences between ITMER_REAL and ITIMER_VIRTUAL I'v put together the following program. #include // exit(), EXIT_FAILURE, EXIT_SUCCESS #include // sigaction() #include // printf(),…
Karl Marklund
  • 485
  • 1
  • 4
  • 10
1
vote
2 answers

how to set multiple Alarms using "setitimer()" function call

I have a requirement to set more than one interval-timers (alarms of same type : ITIMER_REAL) in the same process. so I used setitimer() system call to create 3 alarms with each timer having separate structures to hold time interval values. when any…
reddi hari
  • 173
  • 1
  • 12
1
vote
0 answers

timer values from setitimer

I'm having troubles understanding the timer values filled by setitimer. I have the following code #include #include #include struct itimerval defaultTimer = {{0, 2}, {0, 2}}; struct itimerval disabledTimer = {{0,…
Jona
  • 669
  • 10
  • 18
1
vote
3 answers

the use of getitimer and setitimer in C

I am writing the following C code to get the time taken to perform a simple operation using getitimer and setitimer. #include #include #include #include #include #define INTERVAL 1 /*…
user3236841
  • 1,088
  • 1
  • 15
  • 39
1
vote
2 answers

Run timer for 30 seconds

I want to trigger a timer each second for 30 seconds. However, the timer is triggered only once and the program stops. How to make the timer run for 30 seconds? #include #include void alarmhandler(){ printf("\nTimer…
Saiyan
  • 197
  • 7
  • 22
1
vote
1 answer

why php using ITIMER_PROF but not ITIMER_REAL in setitimer?

PHP under Linux implements ini(max_execution_time) and set_time_limit by using ITIMER_PROF in setitimer, but not ITIMER_REAL. by google it, i found a thread in php.net about this question https://bugs.php.net/bug.php?id=65596. Related to PHP Manual…
suchasplus
  • 50
  • 7
1
2