Safe Queue? … while (next(head) == tail); // block if full

Slides:



Advertisements
Similar presentations
Review: Interrupts & Timers
Advertisements

Deficit Round Robin Scheduler. Outline Introduction Ordinary Problems Deficit Round Robin Latency of DRR Improvement of latencies.
Engineering Open House Need students to demo their players on –Friday 3-4 –Saturday 10-2.
CSC Timers Since this is a microcontroller it mainly finds itself in embedded devices Quite often embedded devices need to synchronize events The.
CSE466 Autumn ‘00- 1 System Functional Requirements  Children’s toy…comes with PC software. Child plays notes on the screen and the device makes corresponding.
Group 4 Rotationally Refreshed Display Patrick Boyd Daniel Hill.
Topics Business Matters –Read Simon Chapter 4 Design Meeting –Some thought RAM might be easier than added SW Complexity … good point. Is it true? –Flow.
CSE Fall Introduction - 1 What is an Embedded Systems  Its not a desktop system  Fixed or semi-fixed functionality (not user programmable)
Embedded Systems Interrupts C.-Z. Yang Sept.-Dec
CSE 466 – Fall Introduction - 1 Remainder of Syllabus  Lecture  RTOS  Maestro In Linux  Distributed Control Architecture – distributed state.
USART interrupt.
Lecture Set 9 MCS-51 Serial Port.
CoE3DJ4 Digital Systems Design Chapter 6: Interrupts.
CSE466 Autumn ‘00- 1 Music Format if amp = 0, note is a command switch(note) 0: turn off specified channel 1: continue for specified tne w/ no change else.
Ethernet Driver Changes for NET+OS V5.1. Design Changes Resides in bsp\devices\ethernet directory. Source code broken into more C files. Native driver.
I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU.
1. Registers Used in Timer/Counter  TH0, TL0, TH1, TL1  TMOD (Timer mode register)  TCON (Timer control register) 2.
Microprocesors, Advanced W hat You Need to Know About RTOSes February 1, 2012 Jack Ganssle.
ECGR-6185 µC/OS II Nayana Rao University of North Carolina at Charlotte.
CSCI1600: Embedded and Real Time Software Lecture 16: Advanced Programming with I/O Steven Reiss, Fall 2015.
EE/CS-352: Embedded Microcontroller Systems Part V The 8051 Assembly Language Interrupts.
Lecture 3 CSE 341 – Microprocessors Lecture 3 Md. Omar Faruqe UB 1228
kashanu.ac.ir Microprocessors Interrupts Lec note 8.
CSE466 Autumn ‘00- 1 Task Diagram music serial music_isr serial_isr OS music time slice…signal music task music time slice os time slice os time slice.
Where Testing Fails …. Problem Areas Stack Overflow Race Conditions Deadlock Timing Reentrancy.
1 Round Robin Non-Preemptive Scheduler Lecture 12.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
80C51 Block Diagram 1. 80C51 Memory Memory The data width is 8 bits Registers are 8 bits Addresses are 8 bits – i.e. addresses for only 256.
Big Picture Lab 4 Operating Systems C Andras Moritz
DEPARTMENT OF ELECTRONICS ENGINEERING V-SEMESTER MICROPROCESSOR & MICROCONTROLLER 1 CHAPTER NO microcontroller & programming.
Outlines  Introduction  Kernel Structure  Porting.
Serial I/O Port.
REAL-TIME OPERATING SYSTEMS
80C51 Block Diagram ECE Overview.
Microprocesors, Advanced What You Need to Know About RTOSes
Topics Covered What is Real Time Operating System (RTOS)
Lesson Objectives Aims Key Words Interrupt, Buffer, Priority, Stack
Source: Serial Port Source:
Architecture Overview (Start here on Fri)
Interrupt and Time Management in µC/OS-III
Round Robin Non-Preemptive Scheduler
Serial I/O and Data Communication.
BVM Engineering College Electrical Engineering Department : Microprocessor and Microcontroller Interfacing Interrupts of 8051 Prepared by:
Interrupt Source: under
CSE 466 – Fall Introduction - 1
Process Synchronization and Communication
Introduction to Micro Controllers & Embedded System Design Interrupt
UNIT 5 TIMRERS/COUNTERS
Source: Serial Port Source:
CSCI1600: Embedded and Real Time Software
Interrupt.
Introduction to Micro Controllers & Embedded System Design Timer Operation Department of Electrical & Computer Engineering Missouri University of Science.
An Embedded Software Primer
Symmetric Multiprocessors: Synchronization and Sequential Consistency
Synchronization Issues
Chapter 2: The Linux System Part 3
8051 Microcontroller.
Last Week Introduced operating systems Discussed the Kernel
Interrupt Source: under
Lecture Topics: 11/1 General Operating System Concepts Processes
Grades.
Interrupt Source: under
Computer Science & Engineering Electrical Engineering
Robocon 2007 Electronics Quickstart!
Source: Serial Port Source:
An Embedded Software Primer
CSE 153 Design of Operating Systems Winter 19
CSCI1600: Embedded and Real Time Software
Source: Serial Port Source:
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

Safe Queue? … while (next(head) == tail); // block if full queue[head] = data; // write data ET0 = 0; // disable T-0 interrupts head = next(head); // update pointer ET1 = 1; // enable T-1 interrupts unsigned char next(unsigned char ptr) { if (ptr == QMX) ptr = 0; else ptr++ return(ptr); }

Consider the compiler C code for blocking queue Compiler output? … while (next(head) == tail); queue[head] = data; ET0 = 0; head = next(head); ET1 = 1; unsigned char next(unsigned char ptr) { if (ptr == 9) ptr = 0; else ptr++ return(ptr); } Compiler output? MOV R0,TAIL MOV R1,HEAD LOOP: ACALL NEXT SUBB A,R0 JZ LOOP MOV R3,#QUEUE ADD R3,R1 MOV @R3,R4 CLR ET0 ACALL NEXT MOV HEAD,A SETB ET0 Assume next() returns value in accumulator, leaves R1 as is

I think we’re safe now volatile data unsigned char tail; … while (next(head) == tail); queue[head] = data; ET0 = 0; head = next(head); ET1 = 1; unsigned char next(unsigned char ptr) { if (ptr == 9) ptr = 0; else ptr++ return(ptr); } MOV R1,HEAD LOOP: ACALL NEXT MOV R0,TAIL ;refresh SUBB A,R0 JZ LOOP MOV R3,#QUEUE ADD R3,R1 MOV @R3,R4 CLR ET0 ACALL NEXT MOV HEAD,A SETB ET0 *compiler knows that sfr’s are volatile (ports, flags)

Embedded Software Architectures No Operating System Round robin: sequential polling for events Round robin w/ interrupts Function Queue Scheduling Real Time Operating System

Maestro w/ Round Robin Only void main (void) { if (TF0) music_task(); // process timer overflow if (R1) serial_input_task(); // process serial input } Would this work for maestro (lab4)? How do we know?

Task Diagram Worst case: character comes one cycle before TF0 Worst Case Latency = max run time of all other tasks serial task main serial music main w.c. latency deadline What is the worst case serial processing time? Depends on response message length--could be bad! How much latency can we tolerate? Practically none timer0 overflow occurs (TF0) char arrives

Round Robin w/ Interrupts volatile bit fEvent; void isr(void) { time_critical_processing(); fEvent = TRUE; } void main (void) { if (R1) serial_input_task(); if (fEvent) { housekeeping(); fEvent = FALSE; Why not put housekeeping into the ISR too? Then our worst case latency to a separate time critical event would be poor Would this work for maestro? See next slide

Maestro in RR+INT What are the time critical functions? Flipping channels, change tones at end of timeslice What are the housekeeping functions? TNE count down and stream processing (TNE, Tones) Do these have hard time constraints too? Yes, one time slice (18ms)…good enough? Not necessarily…serial is undefined! volatile bit fEndOfSlice; void isr(void) { process_tones(); if (!--sliceCount) { changeTones(); sliceCount = SliceSize fEndOfSlice = TRUE; } main () { if (R1) serial_input_task(); if (fEndOfSlice) { if (--TNE==0) process_next_event(); fEndOfSlice = FALSE;

Task Diagram Worst case analysis: character comes one cycle before TF0 Problem: housekeeping can still miss its deadline, depends on serial task execution time time slice start time slice end isr serial housekeeping main deadline timer0 overflow occurs (TF0) char arrives Can we do better?

Benefits Modularization of the Application Some Virtual Machine Features Device Drivers (Virtual Devices)

Embedded Software Software States v. Finite State Machines Hierarchical State Thread/Process Communication Critical Sections Synchronization Messaging and Signaling