Jump to content
  • Advertisement
Sign in to follow this  
Khaos Dragon

interrupts, traps, etc.

This topic is 4975 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!