the Operating System (OS)
-
Upload
cullen-short -
Category
Documents
-
view
43 -
download
2
description
Transcript of the Operating System (OS)
![Page 1: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/1.jpg)
MicroComputer Engineering OperatingSystem slide 1
the Operating System (OS)
![Page 2: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/2.jpg)
MicroComputer Engineering OperatingSystem slide 2
The Operating System (OS)
Operating System
P1: Editor
P2: Compiler
P3: QuakeArena
MIPS
At any one time the processor (MIPS) is only excecuting one program (process).
![Page 3: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/3.jpg)
MicroComputer Engineering OperatingSystem slide 3
The Operating System (OS)
Operating System
P1: Editor
P2: Compiler
P3: QuakeArena
MIPS
At any one time the processor (MIPS) is only excecuting one program (process).
![Page 4: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/4.jpg)
MicroComputer Engineering OperatingSystem slide 4
The Operating System (OS)
Operating System
P1: Editor
P2: Compiler
P3: QuakeArena
MIPS
At any one time the processor (MIPS) is only excecuting one program (process).
![Page 5: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/5.jpg)
MicroComputer Engineering OperatingSystem slide 5
The Operating System (OS)
Operating System
P1: Editor
P2: Compiler
P3: QuakeArena
MIPS
At any one time the processor (MIPS) is only excecuting one program (process).
![Page 6: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/6.jpg)
MicroComputer Engineering OperatingSystem slide 6
The Operating System (OS)
Operating System
P1: Editor
P2: Compiler
P3: QuakeArena
MIPS
At any one time the processor (MIPS) is only excecuting one program (process).
![Page 7: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/7.jpg)
MicroComputer Engineering OperatingSystem slide 7
Our Assembler
.data
.kdata
.text
.ktext
User
Kernel
![Page 8: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/8.jpg)
MicroComputer Engineering OperatingSystem slide 8
The Hardware
.data
.kdata
.text
.ktext
User
Kernel
OKERROR!
![Page 9: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/9.jpg)
MicroComputer Engineering OperatingSystem slide 9
How does the User program pass control to the Operating System?
Take control on ERROR Pass control explicitly
![Page 10: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/10.jpg)
MicroComputer Engineering OperatingSystem slide 10
ERROR
Ex, Arithmetical Overflow li $4 0x80000000 neg $4 $4 (sub $4 $0 $4)
0x00000000 - 0x80000000
0x80000000
Sign differs
Same Sign ! ERROR
![Page 11: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/11.jpg)
MicroComputer Engineering OperatingSystem slide 11
Signed/Unsigned Arithmetics
The only difference is that– Unsigned never causes ERROR
– Signed causes ERROR on Overflow etc.
Signed
ADDSUBADDI..
Unsigned
ADDUSUBUADDIU..
![Page 12: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/12.jpg)
MicroComputer Engineering OperatingSystem slide 12
Memory Error
Instruction Memory = Bad PC Data Alignment Error Access Protected Memory from User mode Nonexistent Memory (Page fault Chapter 7)
![Page 13: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/13.jpg)
MicroComputer Engineering OperatingSystem slide 13
Do not confuse !
A Memory that tells the pipeline to Wait– relate to “cache miss”
A Memory Error or Page Fault– relate to “TLB miss”, more about that later
![Page 14: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/14.jpg)
MicroComputer Engineering OperatingSystem slide 14
The Consequence
A Memory that tells the pipeline to Wait
–Pipeline Stall A Memory Error or Page Fault
–Exception
![Page 15: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/15.jpg)
MicroComputer Engineering OperatingSystem slide 15
Pass Control Explicitly
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 (causes an exception)
![Page 16: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/16.jpg)
MicroComputer Engineering OperatingSystem slide 16
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 Charsyscallori $a0 $r0 0x01 ; Read Charsyscallor $a1 $r0 $v0 ; Move result $v0->$a1ori $a0 $r0 0x00 ; Echo Charsyscall
![Page 17: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/17.jpg)
MicroComputer Engineering OperatingSystem slide 17
Other ways for the Operating System to take control?
External Interrupts, (not caused by User program)– Timers
– Harddisk
– Graphics
– Sound
– Keyboard, Mouse, other perhipals
![Page 18: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/18.jpg)
MicroComputer Engineering OperatingSystem slide 18
Coprocessor CP0
8 Bad Memory Address 12 Status Register 13 Cause Register 14 Exception Address (EPC)
![Page 19: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/19.jpg)
MicroComputer Engineering OperatingSystem slide 19
Status Register CP0 ($12)
“Mode Stack” External Interrupt enable/disable
![Page 20: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/20.jpg)
MicroComputer Engineering OperatingSystem slide 20
“Mode Stack”
OLD PREVIOUS CURRENT
KU IE
0 Kernel Mode1 User Mode
0 External Interrupt Disable1 External Interrupt Enable
KU
IE
KU IEKU IE5 0
![Page 21: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/21.jpg)
MicroComputer Engineering OperatingSystem slide 21
Exception / Interrupt Occurs
OLD PREVIOUS CURRENT
KU IE KU IEKU IE
KU IEKU IE 0 0
0 Kernel Mode1 User Mode
0 External Interrupt Disable1 External Interrupt Enable
KU
IE
![Page 22: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/22.jpg)
MicroComputer Engineering OperatingSystem slide 22
RFE Instruction (priviliged)
OLD PREVIOUS CURRENT
KU IE KU IEKU IE
KU IEKU IE? ?
We restore the PREVIOUS (KU,IE) into CURRENT
![Page 23: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/23.jpg)
MicroComputer Engineering OperatingSystem slide 23
External Interrupts
Bit 0, (Current Interrupt Enable)– All External Interrupts Enable/ Disable
Bit 15..10, (individual interrupt enable)
INT 4 INT 3 INT 2 INT 1 INT 0 Current IE............
INT 5
15 10 0
![Page 24: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/24.jpg)
MicroComputer Engineering OperatingSystem slide 24
Enable External Interrupt 2
Bit 0 = 1, (External Interrupt Enabled) Bit 12 = 1, Interrupt 2 Enabled
Current IE = 1............
15 10 0
INT 4 INT 3 INT 2 INT 1 INT 0INT 5
0 0 0 0 01
![Page 25: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/25.jpg)
MicroComputer Engineering OperatingSystem slide 25
Cause Register (CP0 $13)
Bit 5..2, Exception Cause Code Bit 15..10, Interrupt Pending Bit 31, Exception Occur In Branch Slot
10
INT 5 INT 4 INT 3 INT 2 INT 1 Ex 3 Ex 2 Ex 1 Ex 0BS
5 231 15
INT 0.... .... ...
Exception Cause Codesee LSI Logic User’s Manual
Pending Interrupts
![Page 26: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/26.jpg)
MicroComputer Engineering OperatingSystem slide 26
Check if Interrupt 2 Pending
Mask with bit 12
15 10
INT 4 INT 3 INT 2 INT 1 INT 0INT 5
AND
0 0 0 0 0
CP0 $13
0 0 0 0 01
INT 2
![Page 27: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/27.jpg)
MicroComputer Engineering OperatingSystem slide 27
Resume User Program
CP0 $14 Holds the Exception Address
(Addr to instruction in EX stage)
mfc0 $k0 $14 ; resume address
jr $k0 ; $k0 kernel reg
rfe ; “delayed branch”
![Page 28: the Operating System (OS)](https://reader036.fdocuments.net/reader036/viewer/2022062407/56812b8c550346895d8fa913/html5/thumbnails/28.jpg)
MicroComputer Engineering OperatingSystem slide 28
Shared “Stack”Assume that the User program uses the stack:Can the Kernel use the same stack ($sp)?
Yes, but remember never to use memory below $sp, it will be destroyed (overwritten)!!
$sp
$sp User Data
User Data
User Data
User Data
Kernel Data
Kernel Data