Implementing Operating System #5

What is an Interrupt?

  • Task handler
  • Interrupt handler
  • Trap handler

Creating a Generic Interrupt Handler

interrupt_handlers.s
  • Push the registers on the stack.
  • Call the C function interrupt_handler.
  • Pop the registers from the stack.
  • Add 8 to esp (because of the error code and the interrupt number pushed earlier).
  • Execute iret to return to the interrupted code.

Loading the IDT

global  load_idt

; load_idt - Loads the interrupt descriptor table (IDT).
; stack: [esp + 4] the address of the first entry in the IDT
; [esp ] the return address
load_idt:
mov eax, [esp+4] ; load the address of the IDT into register eax
lidt eax ; load the IDT
ret ; return to the calling function

Programmable Interrupt Controller (PIC)

pic.h
pic.c

--

--

--

Software engineering undergraduate

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Progress Euler

How to deploy a web app for free

Gatsby + Figma + Netlify = Free Landing Page

How to Set Up CMS on Lamp in CentOS 7

Polkadot Launch: Phase 2

How we Built an Android App that Brings Justice

The Ultimate Beginner’s Guide to GraphQL

How Servlet 4.0 and 5.0 are even more convenient than the perfect 3.1

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tharushi Chamalsha

Tharushi Chamalsha

Software engineering undergraduate

More from Medium

BLE Remote Car — Part 1

Circuit diagram for the car

Beware of vendor lock-in

Native vs Cross-Platform Development

Eng Manager Profile: Kamila Lambert

Kamila smiling in front of a brick wall