LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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
 
LinkBack Search this Thread
Old 07-23-2010, 12:58 PM   #1
yaami
LQ Newbie
 
Registered: Jul 2010
Posts: 10

Rep: Reputation: 0
generating timer interrupts in C


Hi all,

I'm trying to understand how interrupts work. Is there a way to generate timer interrupts in C. Any pointers in this regard are appreciated.

Also can we enter into the protected mode of the CPU. Does OS (specifically, linux) place any restrictions on user programs entering protected mode. If it does not, do we just have an assembly language program which changed the mode, followed by the C code... I'm just trying to understand how things work at the lowest level. So I'm trying to write few snippets to test my understanding.

Thanks.
 
Old 07-23-2010, 02:56 PM   #2
jf.argentino
Member
 
Registered: Apr 2008
Location: Toulon (France)
Distribution: FEDORA CORE
Posts: 492

Rep: Reputation: 50
Quote:
I'm trying to understand how interrupts work. Is there a way to generate timer interrupts in C. Any pointers in this regard are appreciated.
Take a look there
Quote:
place any restrictions on user programs entering protected mode.
AFAIK you can't go in restricted mode in userland
 
Old 07-23-2010, 10:21 PM   #3
yaami
LQ Newbie
 
Registered: Jul 2010
Posts: 10

Original Poster
Rep: Reputation: 0
By the way is there a command which provides me with the list of timers, hardware clocks, (watchdog), The address of it and stuff related like frequency.

Thanks.
 
Old 07-24-2010, 02:59 AM   #4
resetreset
Senior Member
 
Registered: Mar 2008
Location: India
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,320

Rep: Reputation: 51
OK, my knowledge is a little rusty in this regard, as it's been about a decade since I dabbled in all this, but - what do you mean GENERATE timer interrupts? Inside your computer is a clock and an 8259A chip, which generates interrupts at a few million times a second, if memory serves me correctly (18.2 is the figure that keeps springing to my mind). When that happens, whatever is running at the moment stops and the CPU goes off to the handler for that interrupt. In a Linux system, I'd guess, that that interrupt is serviced by the scheduler inside the kernel, which handles multitasking, ie. when it gets it, it jumps off to do another task.
You can't ENTER Protected Mode in Linux, it already IS in Protected Mode - it switches to it when booting, it's one of the first things it does. That's why one process can't interfere with another *inside* the OS. You can't write a program to either enter or leave P-Mode INSIDE Linux, otherwise one errant program could crash the system.

If you're getting started learning Assembly Language programming and the lowest level of things, welcome! Wish you the best of luck.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can anyone please explain about "Function call interrupts" entry in /proc/interrupts? cyclops.xmen Linux - Software 2 12-09-2009 12:13 PM
How can I get LAPIC timer to run instead of the PIT timer? sixerjman Linux - Kernel 1 10-16-2007 09:59 PM
Generating Interrupts to the USB sensor device lucky6969b Programming 1 03-31-2006 01:18 AM
generating hardware interrupts 03mcmt02 Linux - Software 1 04-04-2005 04:39 AM
Need to disable timer or all interrupts from user space G35Coupe Linux - General 0 11-16-2004 12:31 AM


All times are GMT -5. The time now is 07:13 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration