Specimen Exam Paper - University of East Anglia

advertisement
UNIVERSITY OF EAST ANGLIA
School of Computing Sciences
Specimen Examination
Embedded Systems
CMPE3D01
Time allowed: 3 hours
Answer 4 questions
Notes are not permitted in this examination.
DO NOT TURN OVER UNTIL YOU ARE TOLD TO DO SO BY THE
INVIGILATOR
(CMPE3D01)
c Copyright of the University of East Anglia
-2-
1. (a) Define the terms ‘rate monotonic scheduling’ and ‘rate monotonic analysis’. What assumptions are made by rate monotonic analysis?
(b) Using a simple scenario, explain the term ‘priority inversion’.
[8 marks]
[6 marks]
(c) Consider the task set shown in Table 1.
Task
Computation Time
Period
Deadline
T1
7
40
20
T2
6
90
40
T3
7
50
30
T4
8
25
12
Table 1 Task Characteristics (milliseconds)
There are three resources:A, B and C. The time required to access each
resource is A: 2 ms; B: 3 ms; and C: 1 ms. The tasks access the resources
once on each release according to Table 2. You may assume that there
Task
A
B
T1
X
X
T2
X
T3
X
X
T4
X
X
C
X
X
Table 2 Resource requirements
are no nested resource accesses (that is, each task can only access one
resource at a time).
(i) Using Deadline Monotonic Priority Assignment, assign priorities to
T1, T2, T3, and T4. Use larger numbers to represent higher priorities.
[2 marks]
(ii) Assuming simple priority inheritance, determine the blocking time of
each task and compute its worst-case response time using response
time analysis. Do any of the tasks miss their deadlines?
[8 marks]
(iii) Assuming priority ceiling inheritance, determine the blocking time of
each task and compute its worst-case response time using response
time analysis. Do any of the tasks miss their deadlines?
(CMPE3D01)
[6 marks]
-3-
2. (a) Briefly explain what needs to be done before a program can use interrupts and why (assume the system uses a Nested Vectored Interrupt
Controller).
[8 marks]
(b) An embedded computer controls a pedestrian crossing. The crossing has
traffic lights for controlling the movement of cars, a button for pedestrians
to press when they wish to cross the road, an illuminated pedestrian
figure and a bleeper for signaling to pedestrians that it is safe to cross.
The required control algorithm is as follows:
• when the system is initialised, the traffic lights are set to green; the
illuminated figure is set to red, the bleeper is off, and the button is
enabled;
• when the button is pressed, the button is disabled;
• after 20 seconds, the traffic lights are turned to amber;
• after a further 10 seconds, the traffic lights are turned to red, the
illuminated figure is turned to green and the bleeper is turned on;
• after a further 30 seconds, the bleeper is turned off, the illuminated
figure is set to flashing green, and the traffic lights are set to flashing
amber;
• after a further 10 seconds, the illuminated figure is set to red, the
traffic lights are set to green and the button is enabled.
The embedded computer has the following 16-bit memory-mapped I/O
registers:
• Button Control Register at address EF 2416 of which bit 6, when
set to 1, enables interrupts (an interrupt signaling that the button
has been pressed). When bit 6 is cleared (set to 0), all but the last
button press is ignored (the last button press is remembered and an
interrupt is generated when bit 6 is again set to 1).
• Bleeper Control Register at address EF 2616 of which bit 8, when
set to 1, turns on the beeper. When bit 8 is cleared, the bleeper is
turned off.
(CMPE3D01)
PLEASE TURN OVER
-4-
• Traffic Lights Data Buffer Register at address EF 2816 . The status
of the traffic lights is determined by the following bit patterns:
– 000016 - all lights off
– 000816 - traffic lights are red
– 000C16 - traffic lights are amber
– 001016 - traffic lights are green
– 001416 - traffic lights are flashing amber
• Illuminated Pedestrian Data Buffer Register at Octal location EF 2A16 .
The status of the illuminated person is determined by the following
bits patterns:
– 000016 - the figure is not illuminated
– 000816 - the figure is illuminated red
– 000C16 - the figure is illuminated green
– 001016 - the figure is illuminated green and flashing
• Interrupts from button presses are vectored and are identified by a
pointer named ’PedestrianCrossingHandler’.
(i) Define a C code data structure for the interface device such that each
register can be accessed using the syntax:
PCC->BUCR; PCC->PDR; etc.
Explain why the type qualifier volatile should be used in the definition.
[10 marks]
(ii) Give an implementation for an interrupt handler to respond to button
presses. You may assume there is a global counter/timer variable
that is incremented every second. Note: The program is not to run
under a real-time operating system.
(CMPE3D01)
[12 marks]
-5-
3. (a) Describe the ARM Cortex-M3 Register structure.
[8 marks]
AREA examQ , CODE, READONLY
ENTRY
EXPORT t e s t
ALIGN
SUB
r1 , r 1
MOV
r0 , r 5
LDRB r0 , [ r 5 ] , #1
CMP
r0 , #0
BEQ
endWhile
ADD
r1 , r1 , #1
BAL while
BX
lr
END
test
while
endWhile
Listing 1 Assembly Subroutine
(b) What is the purpose of assembly code subroutine shown in Listing 1?
Assuming the fragment of code to test the subroutine given in Listing 2,
what will the result be?
[6 marks]
char t e s t s t r i n g = ”CMPE2D02” ;
int r e s u l t ;
t e s t (& t e s t s t r i n g , r e s u l t ) ;
p r i n t f ( ”The r e s u l t i s %d” , r e s u l t ) ;
Listing 2 Test Code
(c) Write an assembly language subroutine that takes an an upper case
ASCII character as input and returns an integer representing the position of the ASCII character in the alphabet (i.e. A = 1, B = 2, etc...).
Note: The ASCII code for ‘A’ is 6510 .
[16 marks]
4. (a) What is an embedded system? Give a definition and list six example
systems.
[5 marks]
(b) Microcontroller architectures are used in many embedded applications.
Describe typical features of a microcontroller and give examples of the
peripherals that it might provide.
[4 marks]
(c) Many embedded systems target real-time applications.
(i) What characterises a real-time system? Give three examples of embedded real-time systems.
[5 marks]
(ii) How do real-time operating systems differ from general purpose operating systems?
[6 marks]
(iii) Describe the features you might expect to be provided by a real-time
operating system kernel and explain why they are useful.
(CMPE3D01)
PLEASE TURN OVER
[10 marks]
-6-
5. (a) Describe the structure of a parallel I/O port by drawing a suitable
diagram.
[12 marks]
(b) Individual output port bits can be configured as push-pull or open drain.
(i) What is the difference between these two output modes?
[6 marks]
(ii) A Light Emitting Diode (LED) is to be illuminated if logic ‘0’ is
written to either parallel I/O port bit 1 OR port bit 2. Draw a
sketch showing how the LED would be connected to the I/O port.
Which output mode would be used?
[6 marks]
(c) Parallel ports used by microcontrollers can sometimes be configured to
provide so-called alternate functions. What does this mean and why is
it useful?
[6 marks]
END OF PAPER
(CMPE3D01)
Download