CS452 - Real-Time Programming - Spring 2013
Lecture 3 - Introduction
Public Service Annoucements
- Due date for assignment 0
- How to compile and run your first
program
- How are you doing at finding a partner?
- Practical Details (pdf):
if you haven't read this yet please do so before the final exam.
Communicating with the Train Controller
The train controller is a slow device. Why? What does slow mean in
practice?
- 2400 bps, 240 bytes per second, 4 milliseconds per byte
- How far does a train go in 4 milliseconds?
- Typical velocity: 50 cm/sec. = 0.05 cm/millisecond
- In 4 milliseconds, 0.2 cm = 2mm
- How long is a tick?
- 10 milliseconds = about one command to the train controller
- Is this an adequate definition of instanteous?
- How long is a train?
- Not all the same length, but typical is 20 cm
- Let's say you want to know where a train is to within a train
length.
- 0.4 seconds to travel a train length.
- How many commands does this amount to?
In contrast,
- How long does it take to write the time to the screen?
- hour (2 bytes), minute (2), second (2), millisecond (2),
punctuation (3), control characters (3-5)
- total about 20 bytes.
- at 115200 bps, 11520 bytes/second
Flow Control
Polling Loops
Polling loops allow you to manage more than one condition/activity pair at
the same time.
The basic polling loop
FOREVER {
if( c1 ) a1;
if( c2 ) a2;
...
if( cN ) aN;
}
A Few Comments
Shallow computation
Worst case response time
- sum over n of {execution time of
if( c<n> ) +
execution time of a<n>}
What you put into an action matters a lot.
Suppose you put busy-wait I/O to the train controller into an action
Will you catch it in your testing?
When you Miss Deadlines
Testing more than once
Suppose you want a better response time for a1. Then try the loop
FOREVER {
if( c1 ) a1;
if( c2 ) a2;
if( c1 ) a1;
if( c3 ) a3;
...
if( c1 ) a1;
if( cN ) aN;
}
Worst case response time for a1
- execution time for
if( c1 ) + maximum over n of execution
time for if( cn ) an
Breaking into pieces
Suppose the response time is still too long, because the execution of one
action, say a2, is too long. Then you can break a2 into two parts
FOREVER {
if( c1 ) a1;
if( c2 ) { a2.1; half-done = TRUE; }
if( c1 ) a1;
if( half-done ) { a2.2; half-done = FALSE; }
...
}
This is strarting to get a little complicated and we haven't said anything
about inter-action communication.
The Hardware/Software Provided
Provided and maintained by CSCF
- Linux systems
- cross compiler: runs on 86_64, produces code for ARM
- GNU toolchain: compiler, assembler, link editor
- You will notice that my makefile separates
- compilation to assembly code,
- assembling the assembly code, and
- link editing.
- need to login explicitly to
linux.student.cs
- TFTP servers
- need to type IP number explicitly
TS-7200
Specific documentation from Technologic
System on Chip (SoC)
EP9302, designed and manufactured by Cirrus semiconductor
Memory
Byte addressable, word size 32 bits
- 32 Mbytes of RAM, starting at
0x00000000
- 4 Mbytes of flash RAM, starting at
0x60000000
- Contains RedBoot, which is loaded into RAM at startup
- Special locations at low addresses
- Special locations above
0x80000000
Two types of special location
- Supplied by Technologic:
0x80840000 to
0x80840047
- Suppied by Cirrus:
0x80010000 to 0x8081ffff
0x808a0000 to 0x80900023
Separate instruction and data caches
`COM' ports
Connected to UARTs
- RS-232
- Actual UART hardware is on the EP9302
Only really two
Ethernet port
Busy wait ethernet code in RedBoot
- used by loader to execute TFTP protocol
- used by RedBoot, which was customized by Technologic and installed in
the Flash RAM
Reset switch
- red, even though documentation says black
- actually, some are black
EP-9302
Specific documentation from Cirrus
System on chip
- ARM 920T core, implementing ARM v4T instruction set
- Specific documentation from ARM
- Two co-processors
- System controller, MMU
- Maverick Crunch floating point unit
- Two interrupt controllers
- Both ARM and Cirrus documentation
- An ARM-designed part, the PL-190
- Peripherals
- UARTs
- Timers
- DIO
- A/D
- etc.
Software
Compiler
GNU tool chain
- when you are getting started optimizing is usually a bad idea
- software multiplication, division, floating point from libgcc.a
- gcc uses a couple of functions like memcpy
- Makefile
- target.ld
RedBoot
Partial implementation
- fconfig :: NOT
- load (tftp)
- examine, copy, fill memory
Returns when program terminates
Busy-wait IO
COM2 uses monitor; COM1 goes to train
- initialization
- output
input
Return to: