Lecture 13 Harvard architecture Coccone OS demonstrator

Slides:



Advertisements
Similar presentations
CPU Structure and Function
Advertisements

Computer Architecture
Computer Organization and Architecture
Computer Organization and Architecture
Chapter 6 Limited Direct Execution
Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
1 Hardware and Software Architecture Chapter 2 n The Intel Processor Architecture n History of PC Memory Usage (Real Mode)
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
Architectural Support for Operating Systems. Announcements Most office hours are finalized Assignments up every Wednesday, due next week CS 415 section.
OS Spring’03 Introduction Operating Systems Spring 2003.
Choice for the rest of the semester New Plan –assembler and machine language –Operating systems Process scheduling Memory management File system Optimization.
1 Last Class: Introduction Operating system = interface between user & architecture Importance of OS OS history: Change is only constant User-level Applications.
Chapter 5 Input/Output I/O Hardware I/O Software Software Layers Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights.
OS Spring’04 Introduction Operating Systems Spring 2004.
Overview von Neumann Model Components of a Computer Some Computer Organization Models The Computer Bus An Example Organization: The LC-3.
1 OS & Computer Architecture Modern OS Functionality (brief review) Architecture Basics Hardware Support for OS Features.
Chapter 2 The OS, the Computer, and User Programs Copyright © 2008.
Group 5 Alain J. Percial Paula A. Ortiz Francis X. Ruiz.
CH12 CPU Structure and Function
9/20/6Lecture 21 -PIC Architecture1 PIC Architecture Programmers Model and Instruction Set.
Computer Organization
80386DX.
OPERATING SYSTEM OVERVIEW. Contents Basic hardware elements.
4-1 Chapter 4 - The Instruction Set Architecture Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring.
Cpr E 308 Input/Output Recall: OS must abstract out all the details of specific I/O devices Today –Block and Character Devices –Hardware Issues – Programmed.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto OS-Related Hardware.
 Virtual machine systems: simulators for multiple copies of a machine on itself.  Virtual machine (VM): the simulated machine.  Virtual machine monitor.
© 2004, D. J. Foreman 1 Computer Organization. © 2004, D. J. Foreman 2 Basic Architecture Review  Von Neumann ■ Distinct single-ALU & single-Control.
© 2004, D. J. Foreman 1 Computer Organization. © 2004, D. J. Foreman 2 Basic Architecture Review  Von Neumann ■ Distinct single-ALU & single-Control.
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.
1 CSE451 Architectural Supports for Operating Systems Autumn 2002 Gary Kimura Lecture #2 October 2, 2002.
Virtual 8086 Mode  The supports execution of one or more 8086, 8088, 80186, or programs in an protected-mode environment.  An 8086.
1.4 Hardware Review. CPU  Fetch-decode-execute cycle 1. Fetch 2. Bump PC 3. Decode 4. Determine operand addr (if necessary) 5. Fetch operand from memory.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
Processor Structure and Function Chapter8:. CPU Structure  CPU must:  Fetch instructions –Read instruction from memory  Interpret instructions –Instruction.
Lecture 26 Virtual Machine Monitors. Virtual Machines Goal: run an guest OS over an host OS Who has done this? Why might it be useful? Examples: Vmware,
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Logical & Physical Address Nihal Güngör. Logical Address In simplest terms, an address generated by the CPU is known as a logical address. Logical addresses.
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.
Virtualization.
ECE 3430 – Intro to Microcomputer Systems
Interrupts and signals
Chapter 8: Main Memory.
Protection of System Resources
Computer Architecture and Organization Miles Murdocca and Vincent Heuring Chapter 4 – The Instruction Set Architecture.
Arithmetic using a stack
OS Virtualization.
Memory Management 11/17/2018 A. Berrached:CS4315:UHD.
Computer-System Architecture
Chapter 8: Memory management
Lecture Topics: 11/1 General Operating System Concepts Processes
Architectural Support for OS
Computer Organization
Operating Systems Lecture 3.
Computer Architecture
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
CSE 451: Operating Systems Autumn 2001 Lecture 2 Architectural Support for Operating Systems Brian Bershad 310 Sieg Hall 1.
Computer System Structures
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
Architectural Support for OS
Lecture 6 CdM-8 CPU overview
Lecture 7 System architecture Input-output
Chapter 11 Processor Structure and function
Lecture 12 Input/Output (programmer view)
Presentation transcript:

Lecture 13 Harvard architecture Coccone OS demonstrator Computing platforms Novosibirsk State University University of Hertfordshire D. Irtegov, A.Shafarenko 2018

Harvard version of CdM-8 Harvard architecture = separate memory banks for data and instruction Can be implemented as: One-bit address extension selecting code and data access (cheap and simple) Separate memory channels (buses) – expensive but boosts performance Memory buses of different width (example: Microchip PIC has 8-bit data and 14-bit instruction memory) Separate cache channels and caches, probably backed by same main memory actually used in some CPU In CdM-8, first approach (bit extension) is used One ISA-level change: ldc (LoaD Constant) instruction to read data from instruction memory

Coccone: most advanced version of CdM-8 Extension of CdM-8 architecture and schematics intended to demonstrate basic concepts of protected-memory operating systems In second semester we offer team project: actually building OS for this machine But what we need to build an operating system?

Processes (tasks) Most (but not all) modern operating systems have concept of process Process is a virtual machine (or a sandbox) with limited access, that runs in isolated memory space Process virtual machine is NOT emulating full access to system hardware (unlike hypervisor virtual machines like VMWare or VirtualBox) All programs you write in C programming course and most other programs you use (including CocoIDE) are designed to be run as processes and use operating system services to access hardware

What we need to protect memory Essentially, we need to catch every memory access for a running program Catch all memory accesses programmatically In fact, we need to interpret entire machine code of your program This is called byte-level interpretation This is how cocoemu actually works Orders of magnitude slower than hardware interpretation Can be significantly sped up by JiT compilation JiT is what Java, C# and many hypervisor virtual machines actually do, but this is far beyond scope of our course

Catch all memory accesses in hardware Insert a hardware device (MMU for Memory Management Unit) between CPU and memory bank Coccone is using one of simplest known types of MMU, known as memory banks Coccone uses 3 previously unused bits in PS register as bank selector In tome.pdf and in Logisim schemes it is also referenced as page Bits 0-3 - CVZN flags, bit 7 - interrupt enable, bits 4-6 - selector So, we can use 8 memory banks 256 bytes each Actually, there are 10 banks, but more on this later

Coccone memory subsystem

Memory banks are not equal Banks 0-3 are reserved for OS code (even simplest OS won’t fit in single bank) When bank 0-3 is active, CPU switches to Harvard mode and can use special 9th bank of RAM for data When bank 4-7 is active, CPU switches to Manchester mode and uses the same bank for code and data Banks 4-7 are for [user] processes Bank 10 is for memory-mapped I/O This is controlled by VBR MMU register (byte 0xff of OS data/IO pages)

VBR (Virtual Bank Register) Not available in “user mode” (code banks 4-7) Can select one of user mode banks, OS data bank I/O page for data access in “system mode” (code banks 0-3)

How to copy data from OS to user bank? 297 ldi r2,data.KBusr # memory bank 298 ld r2,r2 # r2=memory bank 299 300 ldi r0,MMU #r0-> MMU I/O reg 301 st r0,r2 # set data memory bank 302 303 st r1,r3 # set data memory bank 304 inc r1 # advance buffer pointer 305 306 clr r2 # MMU reset to page 0 307 st r0,r2 #

But how to actually switch banks? When we write to bank selector, this is indirect jump (PC now points to different bank but to same position in the bank) One solution: place a same piece of code in every bank This code will handle bank switching This approach is used in many 8-bit CPU with memory banks Actually, this is used in many OS for 32- and 64-bit CPUs. A All OS for x86 are using this approach (OS kernel is mapped to same addresses in all processes)

And how actually change bits 4-6 of PS? We know only two instructions that load and store full PS register: ioi and rti We can use rti to put arbitrary value in PS (push it and then rti) But rti is also a control transfer (considering a previous slide, this is good!) And you can use ioi to call procedures in other banks (just place right PS value at vector 0!) (Actually, many OSes use software interrupts for system calls) Also, special instruction osix with single operand (equivalent to ioi to vector 0, but bits 0-6 of new PS are taken from the operand)

But how interrupts work in multibank system? Where interrupt vectors are placed? What happens to the stack? Coccone always takes interrupt vectors from bank 0 But the vector contains a bank selector, so the handler can be placed in different bank! Coccone stack pointer is shadowed There are actually 8 stack pointers, one for every bank ==one per process But during interrupts, SP[0] is always used, so placing ISR in other banks require extra work

More on osix and rti osix can select target bank and set flags in PS Handler in the bank can use flags and conditional branches to decode syscall number We can have 4x16=64 useful syscalls (pointing to OS code pages) And also 64 useless syscalls pointing to user code pages Useless syscalls actually disturb system operation, so coccone is not as protected as “real” protected memory systems rti can put arbitrary values to PS on return Syscalls can use flags to indicate failure or success Syscalls can pass parameters in registers We’ve seen how syscalls can copy data to user space, so we can pass pointers as parameters