OS Design and Implementation: (Week 6 - 7) - Interrupts & Device Driver; Locks
MIT 6.1810 Fall2025 Course - Week 6-7: Interrupts & Device Driver; Locks

xv6 Book; Chapter 6 - 7 - Interrupts & Device Driver; Locks: https://pdos.csail.mit.edu/6.1810/2025/xv6/book-riscv-rev5.pdf
Chapter 6 and 7 are about Interrupts, device driver and locks.
Interrupts and Device Driver
A driver is the code in an operating system that manages a particular device (network card, mouse, screen...): it configures the device hardware, tells the device to perform operations, handles the resulting interrupts, and interacts with processes using the device
An interrupt is a type of trap that allows a device to communicate with the operating system.
Here are some details about interrupts and device drivers:
The CPU does not directly control I/O devices; instead, it communicates with a microcontroller installed on the devices via a control bus.
Memory-mapped I/O is a communication technique where each device is allocated a specific memory space in RAM, allowing the CPU to read or write data.
Polling, or programmed I/O, is another technique where the OS periodically checks if there is data to read from the device.
Interrupt-based I/O is akin to a trap, as discussed in OS Design and Implementation (Week 4) - Trap.
Locks
Sure! Everyone is familiar with locks: they enable the OS to safeguard shared resources during use.In this chapter, we explore the internals of locks. Although I don't grasp everything, I gain new insights about them.
Labs
There are three labs where we were tasked with building a network driver and adding a custom lock mechanism to xv6. I completed the first one:
[Device Drivers] Network Interface Card (e1000) driver: Implement
e1000_transmitande1000_recvinkernel/e1000.cto manage packet flow by manipulating the hardware's transmit and receive descriptor rings via DMA and control registers. You must successfully pass the "txone" and "rxone" tests by correctly handling buffer allocation, hardware status checks, and synchronization. Completed[Device Drivers] UDP Receive: Implement
ip_rx,sys_recv, andsys_bindinkernel/net.cto enable UDP packet reception by filtering incoming IP traffic, queuing up to 16 packets per bound port, and delivering them to user processes. You must handle the transition between network and host byte orders usingntohs/ntohland ensure the system correctly manages packet buffers to pass allnettestverification suites. I implementedip_rx,sys_bind, i didn't complete thesys_recv.[Locks] Read-Write Lock: You must implement a read-write spinlock in xv6 that allows multiple concurrent readers but ensures exclusive access for a single writer. To prevent writer starvation, your lock must implement a priority scheme where any pending writer blocks new readers from acquiring the lock until the writer has finished.
Next week
Next weeks is about Scheduling.
By the way, here's my GitHub repo for the lab course: https://github.com/TawalMc/MIT-6.1810Fall2025-xv6

