part4 - CS354: Operating Systems Spring 2012 Part 4: OS...

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

View Full Document Right Arrow Icon
1 CS354: Operating Systems Spring 2012 Part 4: OS Interface Dongyan Xu Department of Computer Science Purdue University
Background image of page 1

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

View Full DocumentRight Arrow Icon
Kernel and User Mode Kernel Mode When the CPU runs in this mode: It can execute any machine instruction Examples of privilege instructions: LMSW, SMSW (load/store Machine Status Word register) MOV DBn, MOV CRn (move to debug/control registers) LSL (load stack limit, adjusting stack space available to a process) HLT (halt the CPU) It can access/modify any location in memory It can access and modify any register in the CPU and any device. The OS kernel instructions run in kernel mode.
Background image of page 2
Kernel and User Mode User Mode When the CPU runs in this mode: The CPU can use a limited set of instructions The CPU can only modify only the sections of memory assigned to the process running the program. The CPU can access only a subset of registers in the CPU and it cannot access registers in devices. There is a limited access to the resources of the computer. The user programs run in user mode
Background image of page 3

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

View Full DocumentRight Arrow Icon
Kernel and User Mode When the OS boots, it starts in kernel mode. In kernel mode the OS sets up all the interrupt vectors and initializes all the devices. Then it starts the first process and switches to user mode. In user mode it runs all the background system processes (daemons or services). Then it runs the user shell or windows manager.
Background image of page 4
Kernel and User Mode User programs run in user mode. The programs switch to kernel mode to request OS services (thru the system call interface) Also user programs switch to kernel mode when an interrupt arrives. They switch back to user mode when interrupt returns. The interrupt handling code (part of OS) is executed in kernel mode. The interrupt vector can be modified only in kernel mode. Most of the CPU time is spent in User mode (overhead of mode switch and context switch )
Background image of page 5

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

View Full DocumentRight Arrow Icon
UNIX Interfaces The layers of a UNIX system. User Interface
Background image of page 6
UNIX Kernel
Background image of page 7

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

View Full DocumentRight Arrow Icon
Kernel and User Mode Separation of user/kernel mode is used for: Security: The OS calls in kernel mode make sure that the user has enough privileges to run that call. Robustness: If a process that tries to write to an invalid memory location, the OS will kill the program, but the OS continues to run. A crash in the process will not crash the OS. A bug in user mode causes program to crash, OS still runs. A bug in kernel mode may cause OS and system to crash. Fairness: OS enforces fair access among user processes.
Background image of page 8
Interrupts An interrupt is an event that requires immediate attention. In hardware, a device sets the interrupt line to high. When an interrupt is received, the CPU will stop
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 / 31

part4 - CS354: Operating Systems Spring 2012 Part 4: OS...

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