Sign in to follow this  
Khaos Dragon

interrupts, traps, etc.

Recommended Posts

I am just wondering more about the nature and relationships between interrupts, traps, user, and kernel mode. For example what exactly happens when you issue the printf command? I have done some research on the matter and the following is my conclusion: In general interrupts are generated by hardware devices such as the mouse or the internal clock, by exceptions to improper use of code or possible violations, and by the user himself/user software program in which case it is deemed a trap. And typically the user generates a trap via an OS library call. Now each interrupt has a number associated with it, and various ones use several registers to process information so when an interrupt occurs, a context switch must take place. Then the hardware will look at the interrupt number and retrieve from the interrupt vector table the address of the handler to that interrupt (this is trivial because each address is the same size so simply do something like sizeof(address)*interrupt_number ). Nextly it will load in the handler and execute it. The handler will then issue some sort of return_to_normal_state code. This still leaves the issue of the mode bit and user vs kernel mode. No article I could find specifies its involvement here, but I am guessing the interrupt handler itself toggles the mode bit, or perhaps the mode bit is toggled by hardware when it pushes out an interrupt? So in awnser to that first question, my guess is that when you call printf, the OS pushes a value containing an interrupt number into a queue, and when it is next in the queue, a trap is generated and an interrupt handler itself handles the outputting of the text. [Edited by - Khaos Dragon on February 8, 2005 4:38:10 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this