the Operating System (OS)

Slides:



Advertisements
Similar presentations
Datorteknik OperatingSystem bild 1 the Operating System (OS)
Advertisements

Datorteknik OperatingSystem bild 1 the Operating System (OS)
MIPS ISA-II: Procedure Calls & Program Assembly. (2) Module Outline Review ISA and understand instruction encodings Arithmetic and Logical Instructions.
MIPS ISA-II: Procedure Calls & Program Assembly. (2) Module Outline Review ISA and understand instruction encodings Arithmetic and Logical Instructions.
Some Samples of MIPS Assembly Language Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University.
Datorteknik IOControl bild 1 Input/Output Interface Address bus Data bus Control bus fffffffc Addr DE...Mem 1 Keyboard address decoder Mem n address decoder.
Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
Computer System Overview
Pipeline Exceptions & ControlCSCE430/830 Pipeline: Exceptions & Control CSCE430/830 Computer Architecture Lecturer: Prof. Hong Jiang Courtesy of Yifeng.
Process Description and Control A process is sometimes called a task, it is a program in execution.
What are Exception and Interrupts? MIPS terminology Exception: any unexpected change in the internal control flow – Invoking an operating system service.
MIPS I/O and Interrupt. SPIM I/O and MIPS Interrupts The materials of this lecture can be found in A7-A8 (3 rd Edition) and B7-B8 (4 th Edition).
COMP201 Computer Systems Exceptions and Interrupts.
OPERATING SYSTEM OVERVIEW. Contents Basic hardware elements.
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
MIPS I/O and Interrupt. .data val1:.float 0.6 val2:.float 0.8 msg_done:.asciiz "done\n".text.globl main main: li.s $f0, mfc1 $a0, $f0 jal calsqrt.
Virtual Memory Expanding Memory Multiple Concurrent Processes.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
MicroComputer Engineering OperatingSystem slide 1 the Operating System (OS)
MIPS I/O and Interrupt.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
LECTURE 10 Pipelining: Advanced ILP. EXCEPTIONS An exception, or interrupt, is an event other than regular transfers of control (branches, jumps, calls,
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
Of Privilege, Traps, Interrupts & Exceptions Prof. Sirer CS 316 Cornell University.
Lecture 11 Virtual Memory
An Interrupt is either a Hardware generated CALL (externally derived from a hardware signal) OR A Software-generated CALL (internally derived from.
Interrupts and exceptions
Digital Logic Design Alex Bronstein
Memory The programmer’s model .text, .data .ktext, .kdata
Exceptions Another form of control hazard Could be caused by…
Computer Organization CS224
Handling Exceptions In MIPS, exceptions managed by a System Control Coprocessor (CP0) Save PC of offending (or interrupted) instruction In MIPS: Exception.
MIPS I/O and Interrupt.
Memory The programmer’s model .text, .data .ktext, .kdata
Protection of System Resources
Day 08 Processes.
Day 09 Processes.
Input/Output Interface
MIPS I/O and Interrupt.
Exceptions & Multi-cycle Operations
The Hardware Interface
Pipelining: Advanced ILP
The processor: Exceptions and Interrupts
Structure of Processes
MIPS I/O and Interrupt.
CSCE 212 Chapter 5 The Processor: Datapath and Control
The processor: Pipelining and Branching
Computer System Overview
The University of Adelaide, School of Computer Science
Architectural Support for OS
Project Instruction Scheduler Assembler for DLX
Interrupts and Exception Handling
Virtual Memory Overcoming main memory size limitation
Computer Architecture
A 1-Bit Arithmetic Logic Unit
MIPS I/O and Interrupt.
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Control Hazards Branches (conditional, unconditional, call-return)
Writing an Embedded Controller
Computer System Overview
Architectural Support for OS
ECE/CS 552: Pipelining and Exceptions
System Calls System calls are the user API to the OS
Chapter 11 Processor Structure and function
Interrupts and exceptions
Virtual Memory Use main memory as a “cache” for secondary (disk) storage Managed jointly by CPU hardware and the operating system (OS) Programs share main.
Interrupts and Exception Handling
Presentation transcript:

the Operating System (OS)

The Operating System (OS) Editor Operating System P2: Compiler P3: Doom MIPS At any one time the processor (MIPS) is only excecuting one program (process).

Our Assembler .text .data User .ktext .kdata Kernel

The Hardware .text .data User ERROR! OK .ktext .kdata Kernel

How does the User program pass control to the Operating System? Take control on ERROR Pass control explicitly

ERROR Ex, Arithmetical Overflow li $4 0x80000000 neg $4 $4 (sub $4 $0 $4) 0x00000000 - 0x80000000 0x80000000 Sign differs Same Sign ! ERROR

Signed/Unsigned Arithmetics The only difference is that Unsigned never causes ERROR Signed causes ERROR on Overflow etc. Signed ADD SUB ADDI .. Unsigned ADDU SUBU ADDIU ..

Memory Error Instruction Memory = Bad PC Data Alignment Error Access Protected Memory from User mode Nonexistent Memory (Page fault Chapter 7)

Do not confuse ! A Memory that tells the pipeline to Wait relate to “cache miss” A Memory Error or Page Fault realte to “TLB miss”

The Consequence A Memory that tells the pipeline to Wait Pipeline Stall A Memory Error or Page Fault Exception

Pass control excplicitly The User wants some service from the Operating System File I/O Graphics Sound Allocate Memory Terminate Program (no HALT instruction in real MIPS) SYSCALL (casuses an exception)

How to choose service: Is there different SYSCALLs? NO! Only one, use a register ($a0) to choose Use other registers ($a1,...) as parameters Use $v0 for result ori $a1 $r0 ‘A’ ; Char ‘A’ ori $a0 $r0 0x00 ; Write Char syscall ori $a0 $r0 0x01 ; Read Char or $a1 $r0 $v0 ; Move result $v0->$a1 ori $a0 $r0 0x00 ; Echo Char

Other ways for the Operating System to take control? External Interrupts, (not caused by User program) Timers Harddisk Graphics Sound Keyboard, Mouse, other perhipals

Coprocessor CP0 8 Bad Memory Address 12 Status Register 13 Cause Register 14 Exception Address

Status Register “Mode Stack” External Interrupt enable/disable

“Mode Stack” OLD PREVIOUS CURRENT KU IE KU IE KU IE KU IE 5 KU IE KU IE KU IE KU IE 0 Kernel Mode 1 User Mode 0 External Interrupt Disable 1 External Interrupt Enable

Exception / Interrupt Occurs OLD PREVIOUS CURRENT KU IE KU IE KU IE KU IE KU IE 0 0 KU IE 0 Kernel Mode 1 User Mode 0 External Interrupt Disable 1 External Interrupt Enable

RFE Instruction (priviliged) OLD PREVIOUS CURRENT KU IE KU IE KU IE ? ? KU IE KU IE We restore the PREVIOUS (KU,IE) into CURRENT

Resume User Program CP0 $14 Holds the Exception Address (Addr to instruction in EX stage) mfc0 $k0 $14 ; resume address jr $k0 ; $k0 kernal reg rfe ; “delayed branch”

Shared “Stack” Assume that the User program uses the stack: Can the Kernal use the same stack ($sp)? Yes, but remember never to use memory below $sp, it will be destroyed (overwritten)!! $sp Kernal Data Kernal Data $sp User Data User Data User Data User Data

External Interrupts (CPO $14) Bit 0, (Current Interrupt Enable) All External Interrupts Enable/ Disable Bit 15..10, (individual interrupt enable) 15 10 Current IE INT 5 INT 4 INT 3 INT 2 INT 1 INT 0 ............

Enable External Interrupt 2 Bit 0 = 1, (External Interrupt Enabled) Bit 12 = 1, Interrupt 2 Enabled 15 10 INT 5 INT 4 INT 3 INT 2 INT 1 INT 0 Current IE = 1 1 ............

Cause Register (CP0 $13) Bit 5..2, Exception Cause Code Bit 15..10, Interrupt Pending Bit 31, Exception Occur In Branch Slot 31 15 10 5 2 BS INT 5 INT 4 INT 3 INT 2 INT 1 INT 0 Ex 3 Ex 2 Ex 1 Ex 0 .... .... ... Pending Interrupts Exception Cause Code see Table 4.3 LSI Logic

Check if Interrupt 2 Pending Mask with bit 12 15 10 CP0 $13 INT 5 INT 4 INT 3 INT 2 INT 1 INT 0 AND 1 INT 2