l06-trap - W4118: interrupt and system call Junfeng Yang...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
W4118: interrupt and system call Junfeng Yang
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Outline Motivation for protection Interrupt System call 2
Background image of page 2
Need for protection Kernel privileged, cannot trust user processes User processes may be malicious or buggy Must protect User processes from one another Kernel from user processes 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Hardware mechanisms for protection Dual model of operation Privileged (+ non-privileged) operations in kernel mode Non-privileged operations in user mode Memory protection Segmentation and paging • E.g., kernel sets page table when creating process Timer interrupt Kernel periodically gets back control 4
Background image of page 4
What operations are privileged? Read raw keyboard input Call printf() Call write() Write global descriptor table Divide by 0 Set timer interrupt handler Set segment registers Load cr3 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
x86 protection modes Four modes (0-3), but often only 0 & 3 used Kernel mode: 0 User mode: 3 “Ring 0”, “Ring 3” Segment has Descriptor Privilege Level (DPL) DPL of kernel code and data segments: 0 DPL of user code and data segments: 3 Current Privilege Level (CPL) = current code segment’s DPL Can only access data segments when CPL <= DPL 6
Background image of page 6
Outline Motivation for protection Interrupt System call 7
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
OS: “event driven” Events causing mode switches System calls : issued by user processes to request system services Exceptions : illegal instructions (e.g., division by 0) Interrupts : raised by devices to get OS attention Often handled using same hardware mechanism: interrupt Also called trap 8
Background image of page 8
while (fetch next instruction) { run instruction; if (there is an interrupt) { process interrupt } } 9
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 25

l06-trap - W4118: interrupt and system call Junfeng Yang...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online