real real time systems time systems low low level
play

Real Real- -Time Systems Time Systems Low- Low -level - PowerPoint PPT Presentation

EDA222/DIT160 Real-Time Systems, Chalmers/GU, 2008/2009 Lecture #6 Updated 2009-02-01 Real Real- -Time Systems Time Systems Low- Low -level programming level programming Low- Low -level programming in Ada 95 enables writing level


  1. EDA222/DIT160 – Real-Time Systems, Chalmers/GU, 2008/2009 Lecture #6 Updated 2009-02-01 Real Real- -Time Systems Time Systems Low- Low -level programming level programming Low- Low -level programming in Ada 95 enables writing level programming in Ada 95 enables writing device device drivers for I/O circuits directly in a high for I/O circuits directly in a high- -level language. level language. drivers • Low-level programming Specification • Resource management For systems programmed in a high- For systems programmed in a high -level language without level language without • Deadlock and starvation support for low- -level programming, device drivers must level programming, device drivers must support for low be written in the processor be written in the processor’ ’s assembly language. s assembly language. Implementation Calling a device driver facilitates reading or writing data Calling a device driver facilitates reading or writing data to/from external units, e.g., hard disks, displays and to/from external units, e.g., hard disks, displays and keyboards. keyboards. Verification A device driver conceals the details in the cooperation A device driver conceals the details in the cooperation between software and hardware. between software and hardware. Low- -level programming level programming Interrupt controlled I/O Low Interrupt controlled I/O The programming language should make it possible to: The programming language should make it possible to: Interrupt controlled I/O has the following advantages: Interrupt controlled I/O has the following advantages: • Declare data types that enables manipulation of individual bits • Program controlled I/O uses ”polling”, which means that the and bit strings. processor spends most of its time in a ”busy-wait” loop. • Define how declared variables are represented in the hardware. • In many systems, one cannot afford to let the processor waste • Read and write from/to hardware addresses where data and capacity in busy-wait loops. Interrupt controlled I/O avoids this. control registers of I/O circuits are located. • By activating the I/O handling code only when it is actually • Implement interrupt controlled I/O (i.e., associate hardware needed, it is easy to model a system event as a task. interrupts with high-level procedures for servicing the interrupt). • Depending on the activation pattern of the system event, it can be modeled as a periodic (e.g., interrupt from real-time clock) or aperiodic (e.g., network communication) task. 1

  2. EDA222/DIT160 – Real-Time Systems, Chalmers/GU, 2008/2009 Lecture #6 Updated 2009-02-01 Interrupt handling in Ada 95 Interrupt handling in Ada 95 Interrupt handling in Ada 95 Interrupt handling in Ada 95 Important guidelines for interrupt handling: Important guidelines for interrupt handling: Procedure for implementing the interrupt handler: Procedure for implementing the interrupt handler: • Interrupts in must be handled using protected objects. 1. Declare a protected object and write the interrupt service • The interrupt service routine must be written as a procedure routine as a procedure in the protected object. in the protected object. 2. Inform the compiler that the procedure is an interrupt service routine, by adding the statement • Data being handled by the interrupt service routine must be stored in local variables in the protected object. pragma Interrupt_Handler( procedure_name ); • Reading and writing such data from the Ada program code in the specification of the protected object. must be done via calls to functions, entries or procedures in the protected object. 3. Declare a variable and assign to it the logical number of the hardware interrupt signal. For example: Int_ID : constant := Ada.Interrupts.Names. int_name ; Interrupt handling in Ada 95 Interrupt handling in Ada 95 Interrupt handling in Ada 95 Interrupt handling in Ada 95 Procedure for implementing the interrupt handler (cont’ Procedure for implementing the interrupt handler (cont ’d): d): Why is it important that a ceiling priority is defined for Why is it important that a ceiling priority is defined for the protected object? the protected object? 4. Associate the interrupt service routing with the logical number • When an interrupt is requested, the processor hardware of the hardware interrupt signal, by calling the procedure causes the interrupt service routine to be executed at a priority Attach_Handler( procedure_name ’ access , Int_ID); level associated with the interrupt signal. • Functions, entries, and procedures in the protected object 5. Inform the compiler about the ceiling priority of the protected must execute at the same priority level as the interrupt service object, by adding the statement routine in order to preserve the mutual exclusion properties of pragma Interrupt_Priority( priority ); the protected object. • A task that calls a function, entry or procedure in the protected in the specification of the protected object. object temporarily assumes the ceiling priority while executing The ceiling priority must be identical to the priority of the code in the protected object. corresponding hardware interrupt signal. 2

  3. EDA222/DIT160 – Real-Time Systems, Chalmers/GU, 2008/2009 Lecture #6 Updated 2009-02-01 Gnu Ada 95 M68K Gnu Ada 95 M68K Gnu Ada 95 M68K Gnu Ada 95 M68K Package System contains the following declarations: Package Ada.Interrupts contains the following declarations: subtype Any_Priority is Integer range 1..105; package Ada.Interrupts is subtype Priority is Any_Priority type Interrupt_ID is 64..80; range Any_Priority’First .. 100; ... subtype Interrupt_Priority is Any_Priority end Ada.Interrupts; range Priority’Last .. Any_Priority’Last; The priority of a protected object can be defined with Package Ada.Interrupts.Names contains the following declarations: pragma Interrupt_Priority[( expression )]; package Ada.Interrupts.Names is Priority levels that are so high that they will mask (block) one or TIMEINT : constant Interrupt_ID := 64; ITIMERINT : constant Interrupt_ID := 65; more hardware interrupt signals are of type Interrupt_Priority . PORTBINT : constant Interrupt_ID := 66; end Ada.Interrupts.Names; In Gnu Ada 95 M68K, the priority levels 101..105 correspond to the processor’s (Motorola 68340) hardware priorities 1..5. Resource management Resource management Resource management Resource management Resource management is a general problem that exists Resource management is a general problem that exists Classification of resources: Classification of resources: at several levels in a real- -time system. time system. at several levels in a real • Shared resources can be accessed by multiple users at the • The run-time system manages internal resources in the same time. computer, e.g., CPU time, memory space, disks and • Exclusive (non-shared) resources can only be accessed by communication channels. one user at a time. • The application program manages other resources, that – can be guaranteed with mutual exclusion represents the controlled system, e.g., track sections in a – program code that is executed while mutual exclusion applies train control system or robots in a manufacturing system: is called a critical region – Data structures and files – Sensors and actuators – Monitors and keyboards. 3

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend