Project 2, Interrupts, and Scheduling
CS 4411 Spring 2020
and Scheduling CS 4411 Spring 2020 Announcements Office hours - - PowerPoint PPT Presentation
Project 2, Interrupts, and Scheduling CS 4411 Spring 2020 Announcements Office hours Regrades Piazza Outline for Today Arrays and Stacks Project 2 Overview Interrupt Handling Privilege Modes Timer Interrupts
CS 4411 Spring 2020
downward”
Stack Heap Code Data Kernel 0x00000000 0xFFFFFFFF
Virtual addresses SP
push pop
0x6FAA00 arr[o] arr[1] arr[2] arr[3] 0x6FAA04 0x6FAA08 0x6FAA0C 0x6FAA10 arr + 3 * sizeof(int) 0x6FAA00
int[4] arr;
arr
0x6FAA00 arr[o] arr[1] arr[2] arr[3] 0x6FAA04 0x6FAA08 0x6FAA0C 0x6FAA10 arr
Register 2 Register 1
sp
Register 3 Register 4
push
int[4] arr; stack
lowest memory address in the allocated region
(Can you use arr as a stack pointer?)
int* arr = malloc(4 * sizeof(int));
0x6FAA00 arr 0x6FAA00 0x6FAA10
macro to select whether new or old code is compiled:
#ifdef HW_MLFQ proc_next = mlfq_get_next(&run_queue, level); #else proc_next = queue_get(&proc_runnable); #endif
your code will be used, otherwise original code will be used
Original (round- robin) code Your new code
where CPU jumps
location, has an entry for each type of interrupt
Interrupt Controller CPU Devices IV Memory
Interrupt Handler Program Signals Interrupt
User process
User mode Kernel mode
User process Keyboard interrupt handler Disk interrupt handler
is running
memory must also be mapped in process’s address space
handler’s code?
Stack Heap Code Data Kernel
SP PC
process’s entire memory space
Stack Heap Code Data Kernel
SP PC Kernel stack
proc_got_interrupt() in process.c for all interrupts
Other Types of Interrupts
you!
something!
Timer Interrupts
the kernel, even for long- running processes
process – pre-emption
User mode Kernel mode
Process 1 Process 2 Process 1 P 2
read() syscall Disk interrupt Timer interrupt
Disk interrupt handler System call routine Timer interrupt handler
Process 1
Time
Process 2 P 3 P 1 Blocks and waits 10ms P 2 P 3 P 1 Blocks and waits I/O finally ready
User mode Kernel mode
P1 P1 P1 P1 P1 P2
Kernel’s tick counter:
1 2 3 4 5
Process 1 Process 2 P 3 P 1 10ms P 2 P 3 P 1 Timer interrupts Syscall Syscall
reaches the end of a quantum without blocking?