Professional Documents
Culture Documents
Class Test Merged
Class Test Merged
Class Test Merged
A single purpose processor is a state-machine which is designed to execute exactly one program.
int total = 0;
<assignment-operator> ::= =
| *=
| /=
| %=
| +=
| -=
| <<=
| >>=
| &=
| ^=
| |=
If a task wants to use Device A, it should check the status by reading the variable
DeviceALocked. If it is zero, it can write a 1 to DeviceALocked to lock the device.
After it’s finished using the device, it can then clear the DeviceALocked to zero so that other
tasks can use it.
What will happen if two tasks try to access Device A at the same time ?
In that case, possibly both the tasks will read the variable DeviceALocked, and both will get
zero. Then both of them will try writing back 1 to the variable DeviceALocked to lock the device, and
we’ll end up with both tasks believing that they have exclusive access to Device A.
THIS IS WHERE, exclusive accesses are used. The STREX instruction has a return status, which indicates
whether the exclusive store has been successful. If two tasks try to lock a device at the same time, the
return status will be 1 (exclusive failed) and the task can then know that it needs to retry the lock.
Note that the data write operation of STREX will not be carried out if the exclusive monitor returns a fail
status, preventing a lock bit being set when the exclusive access fails.
If the return status of this function LockDeviceA is 1 (exclusive failed), the application tasks should wait a
bit and retry later. In single-processor systems, the common cause of an exclusive access failing is an
interrupt occurring between the exclusive load and the exclusive store. If the code is run in privileged
mode, this situation can be prevented by setting an interrupt mask register such as PRIMASK for a short
time to increase the chance of getting the resource locked successfully.
In multiprocessor systems, aside from interrupts, the exclusive store could also fail if another processor
has accessed the same memory region. To detect memory access from different processors, the bus
interface requires exclusive access monitor hardware to detect whether there is an access from a
different bus master to a memory between the two exclusive accesses.
With this mechanism, we can be sure that only one task can have access to certain resources. If the
application cannot gain the lock to the resource after a number of times, it might need to quit with a
timeout error. For example, a task that locked a resource might have crashed and the lock remained set.
In these situations, the OS should check which task is using the resource. If the task has completed or
terminated without clearing the lock, the OS might need to unlock the resource.
If the process has started an exclusive access using LDREX and then found that the exclusive access is no
longer needed, it can use the CLREX instruction to clear the local record in the exclusive access monitor.
For CortexM3, all exclusive memory transfers must carry out sequentially. However, if the exclusive
access control code has to be reused on other ARM cores, the Data Memory Barrier (DMB) instruction
might need to be inserted between exclusive transfers to ensure correct ordering of the memory
accesses.
Since the bit 0 of the program counter (PC) is always zero, the value in the branch table is multiplied by 2
before it is added to PC. Furthermore, because the PC value is the current instruction address plus 4, the
branch range for the TBB is (2 * 255) + 4 = 514.
The branch range for the TBH is (2 * 65535) + 4 = 131074. Both TBB and TBH support forward branch
only.
Acknowledgements :: The Definitve Guide to ARM CortexM3 – Joseph Yiu
b> If each LUT takes 5ns intrinsic delay, what would be the total delay for the conversion.
d> Assume you had a 6bit LUT. Then what would be the total delay for the conversion.
0 0 0 0 0 0
0 0 1 0 1 1
0 1 0 1 1 0
0 1 1 1 0 1
1 0 0 1 0 0
1 0 1 1 1 1
1 1 0 0 1 0
1 1 1 0 0 1
The logic would look like the below. For this there is need for only 2 LUT’s. (3 with pass through is also
correct answer). The g0 b0 can be implemented through simple interconnect.
b>
Since the LUT’s would be in parallel, the intrinsic delay of the full conversion will also be 5ns.
c> For a 6 input LUT there would be no change in total delay of conversion for this example.
Class Test – Part 6
For a Car Controller scheduler, Let C = worst case execution time, T =
(sampling) period, D = deadline.
a> Speed Measurement : C = 4ms, T = 20ms, D = 20ms
b> ABS Control : C = 10ms, T = 40ms, D = 40ms
c> Fuel Injection : C = 40ms, T = 80ms, D = 80ms
2> Create a time table of the tasks (schedulable or non-schedulable). If there is a slack, mention the
same.
4> Assume that each context switch takes 0.25ms. Redraw the time table of the tasks.
1> The set of tasks are schedulable.
2> Timetable is as follows, Initial slack is 4ms