LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-13-2002, 01:57 AM   #1
bos
LQ Newbie
 
Registered: Mar 2002
Posts: 2

Rep: Reputation: 0
using the timer interrupt


Hi,

I have a (hopefully) small question:

I need my code to execute every time tick.
How can i use the timer interrupt? Do I need to share it with the timer (as I've seen in /proc/interrupt, timer uses the timer interrupt)?

Thanks
 
Old 03-15-2002, 10:38 AM   #2
lavelle
LQ Newbie
 
Registered: Mar 2001
Location: Dallas TX
Distribution: RH7.2 RH7.0
Posts: 12

Rep: Reputation: 0
I don't know what language you are using so I'll show you a perl example. Perl is simpler as you don't need to set signal masks.

What you are probably looking for is the alarm call do a man alarm to see how to use the system call. Basically you tell the OS to send you an ALRM signal in X number of seconds then make sure your program will catch that signal when it arrives.

Here is an example in Perl:

#!/usr/bin/perl

sub alarm
{
print "Are you done yet\n";
alarm(10); #reschedule the alarm in 10 seconds
}

$SIG{ALRM}=\&alarm; #assign the signal handler
alarm(5);
print "Type something in then press enter\n";
<STDIN>; #read and throw away user input
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
About timer.... help rajsun Programming 3 05-24-2005 06:06 AM
Custom Timer Interrupt Handler Linux 2.4x ratwings Linux - Software 2 01-13-2005 01:51 AM
<0>Kernel panic: Aiee, killing interrupt handler! In interrupt handler - not syncing mrb Linux - Newbie 2 01-09-2005 09:47 AM
Timer Interrupt Handler opereira Programming 1 03-03-2004 04:57 PM
A timer LOUDSilence Programming 1 12-08-2003 05:49 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration