1 / 27

CSCI1600: Embedded and Real Time Software

This lecture explores the issues related to real-time programming, including small footprint, efficient use of memory and hardware, access to devices, interrupts, and secure and reliable code. It also discusses the criteria for choosing a programming language, comparing C, C++, Assembler, and Java, and highlights the challenges and benefits of using Java for real-time programming. Additionally, it covers Embedded Java and J2ME configurations and profiles for embedded systems.

annelandry
Télécharger la présentation

CSCI1600: Embedded and Real Time Software

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSCI1600: Embedded and Real Time Software Lecture 20: Real Time Programming Steven Reiss, Fall 2016

  2. Embedded Programming Issues • Small footprint • Efficient use of memory • Efficient use of hardware • Access to hardware • Inputs and outputs • Interrupts • Secure and reliable code • Low power consumption Lecture 20: Real Time Programming

  3. Real Time Programming Issues • Predictable performance • Predictable scheduling • Synchronization mechanisms • Interrupts with performance guarantees • Reliable, secure code Lecture 20: Real Time Programming

  4. Programming Language Wars Lecture 20: Real Time Programming

  5. Programming Languages • For real-time and embedded programming • Choices • Assembler • C/C++ (low-level language) • Java/C# (high-level language) • Data flow languages (FPGA) • Python, Ruby, JavaScript • Other • How should we choose? Lecture 20: Real Time Programming

  6. Criteria for Choosing • Small footprint for embedded systems • Ability to write small code • Ability to make efficient use of memory • High performance • Predictable performance • Real time features • Interrupts • Scheduling tasks or threads • Synchronization • Matching the CPU model Lecture 20: Real Time Programming

  7. Criteria For Choosing • Access to devices, physical memory • Low Power consumption • Security and Reliability • Other factors • Fault tolerance • Code understandability Lecture 20: Real Time Programming

  8. C versus C++ versus Assembler • Footprint • Performance • Real time features • Interrupts, synchronization, scheduling control • Fault tolerance • Reliability • Security • Understandability Lecture 20: Real Time Programming

  9. Why Not Java • What are the pros and cons? Lecture 20: Real Time Programming

  10. What about Java • Not what Java was designed for • Potential problems • Java has the reputation of being slow & unpredictable • Java programs are large • Garbage collection and run time checks seem a bad idea • Interpreted languages are too slow Lecture 20: Real Time Programming

  11. Reasons to Use Java • Don’t want to give up a language we are used to • Java programs are more reliable • Many errors caught at source/run time level • More secure • Safety is critical • Easier to verify • Exceptions, threads, synchronization built in • Data structures that are thread safe Lecture 20: Real Time Programming

  12. Using Java • J2ME is the primary effort (pJava was predecessor) • Addresses embedding issues • JSR001 is a Java extension proposal • Addresses real-time issues • Understanding these helps understanding • Embedded and real time programming in general Lecture 20: Real Time Programming

  13. Embedded Java • Basic Problems • VM, JIT compiler, libraries are big (64M, 256M) • Scheduling abstraction used for threads is not fixed priority • Java emphasizes device independence • No access to physical memory (IO) • How can these problems be addressed? Lecture 20: Real Time Programming

  14. Java ME • Attempts to address size & independence issues • Organized in terms of configurations • Configuration = broad range of similar devices • Determines what libraries to include • Determines JVM features to include • Scalable OS • Select the features needed for the application • No verification, finalization, class loader, thread groups, reflection • Limited I/O, error handling • Limited data types (no 64 bit, no multidimensional arrays) • Current base configuration: 128K ram, 1M ROM Lecture 20: Real Time Programming

  15. J2ME Configurations • Connected Devise Configuration • Limited set of library classes • 32 bit, 4MB memory required • Most code sits in ROM • Connected Limited Device Configuration • Even more limited • 16 bit processors • 512K memory required Lecture 20: Real Time Programming

  16. J2ME Profiles • Support sets of similar devices • Mobile Information Device Profile • Touch screen or keypad, 96x54 or larger display • Wireless networking • Runs with 32k ram, 8k eeprom, 128k flash • Used in PDAs, mobile phones, pagers • Optional packages • Mobile Media API support multimedia applications • Other Embedded Javas • Java Card – applet on a smart card • Java TV – for set top boxes Lecture 20: Real Time Programming

  17. Java Real Time • Embedding is easy • Just pare down the language and libraries • Real time requirements are more difficult • Affect the execution model of the language • Nothing in Java spec makes wall-clock guarantees • Garbage collection pauses do not affect the semantics • Thread priorities exist but aren’t well defined Lecture 20: Real Time Programming

  18. Compiled Approach • Fiji VM • Precompile Java to C • OS includes the garbage collector • Overhead about 30% over straight C code • Max time of about 10% long • But this is experimental, not a guarantee Lecture 20: Real Time Programming

  19. JSR1: Real Time Java Specification • Thread scheduling and dispatch (tasks) • Memory management • Synchronization and resource sharing • Asynchronous event handling • Asynchronous transfer of control • Asynchronous thread termination • Physical memory access • JSR282: Update (fix problems) • JSR302: safety-critical extensions Lecture 20: Real Time Programming

  20. Thread Scheduling • Basic real-time scheduler is included • Priority based and preemptive • At least 28 priority level • Can define your own schedulers • Schedulable Objects • RealtimeThread :: uses real time scheduler • NoHeapRealtimeThread:: may not allocate or reference normal heap • Can run in preference to GC • GC can be preempted Lecture 20: Real Time Programming

  21. Memory Management • Garbage collection is a problem • Not that it exists, but that it makes response time unpredictable • Why not just interrupt the garbage collector • Needs to lock all of memory? • Actually needs to lock all of garbage collected memory • Hence create memory areas that are separate Lecture 20: Real Time Programming

  22. Memory Management • Memory Areas • Regions of memory outside of traditional Java heap • Don’t have to e garbage collected • Scoped Memory • For objects that have a lifetime defined by the scope • Physical memory • Specific regions for specific purposes • Immortal memory • Never collected • Budgeted allocation • Limit allocation for a schedulable objet • Can be preallocated Lecture 20: Real Time Programming

  23. Synchronization • Problems • Synchronized data structures • Interactions with scheduling • Blocking times as part of max response time • Wait Queues as a primitive class • Dealing with priority problems • Priority inheritance supported • Priority ceiling emulation supported • Wait-free classes for non-blocking shared access • Fixed upper bound on entering an unlocked synchronized block Lecture 20: Real Time Programming

  24. Asynchronous Event Handling • Bind handlers to internal and external events • External events • Signals, timers, interrupts (classes to support these) Lecture 20: Real Time Programming

  25. Asynchronous Transfer of Control • Can you interrupt or stop a thread in Java? • What do Thread.interrupt() and Thread.stop() do? • Schedulable objects • Can declare throws AsynchronouslyInterruptedException • These can be safely interrupted • When interrupted, interruptAction() is invoked • Can stop a thread through implicit exceptions Lecture 20: Real Time Programming

  26. Real Time Java Implementations • Fuji Compiled Java • Timesys reference implementation • IBM’s WebSphere Real Time • Oracle Java SE Real-Time system • PTC Perc • JamaicaVM from aicas Lecture 20: Real Time Programming

  27. Homework • Project Design Presentations • Present you project to the class • Plans, progress to date • Project model • Tasks and model(s) for each task • Hand this in • Can be part of presentation Lecture 20: Real Time Programming

More Related