User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

lab_11 [2019/04/08 20:11] (current)
Line 1: Line 1:
 +====== Lab 11: Utilization ======
 +===== Overview =====
 +In this lab you shall use the principles taught in chapter 11 to calculate utilization on a microcontroller running multiple tasks and predict if timer overrun will occur in the worst-case situation.
 +===== Specifications =====
 +In Section 11.3 of the book, worst-case execution time (WCET) is calculated based off the number of assembly instructions. We could count assembly instructions in the .elf files generated by the Xilinx SDK, but this is difficult to do except in the simplest cases. Your code probably contains conditional statements, function calls, etc... which complicate finding the worst-case number of instructions. Instead of counting or trying to predict the number of assembly instructions we shall use a timer to measure WCET of each task.
 +Analyze the utilization of Lab 8, the task scheduler lab. You may want to create a new project and copy and paste the code because you will need to make some code modifications. Use a timer to calculate the WCET of each task in Lab 8. Determine if timer overrun may occur in the worst-case situation within a hyperperiod by using this method from the book:
 +''"​Checking if the sum of WCETs for all tasks exceeds the smallest period of any task will indicate whether a timer overrun will occur in that worst-case situation."''​
 +Here is the process for using the timer to measure the WCET of a task:
 +  - At the beginning of the task reset and start the timer.
 +  - At the end of the task stop the timer and read its value. Update the WCET if necessary based on the timer'​s value.
 +Recall that each AXI timer actually contains two timers and you probably only used one of them in Lab 8. Your code from Lab 8 should already include the initialization of an AXI timer. It probably also sets the reset value and options for timer0 in the AXI timer. You probably did not use timer1 of the AXI timer so you will use it now for measuring the WCET of each task. If your code does use both timers of the AXI_TIMER_0 then you will need to initialize and use AXI_TIMER_1 instead. **You do not need to set a reset value or options for the timer you will use to measure the WCETs because the default settings are sufficient.** When you call functions to start, stop, reset, or read the timer be sure that you are performing these actions on the correct timer or you may interfere with the timer that is generating interrupts.
 +Modify the task struct so that it includes a field for WCET as shown below. Your code should update this field when necessary.
 +typedef struct task {
 +   int state; ​                 // Task's current state
 +   ​unsigned long period; ​       // Task period
 +   ​unsigned long elapsedTime; ​ // Time elapsed since last task tick
 +   int (*TickFct)(int); ​       // Task tick function
 +   u32 wcet;​ //​ Task's worst-case execution time
 +} task;
 +You may use print statements (xil_printf or printf) to display the WCET values. Make sure you do not print the WCET values when the timer is still running.
 +===== Notes =====
 +If some of your tasks have print statements inside them, find the WCET for the task both with and without the print statement(s). Note this difference in the paper you hand in.
 +===== Grading =====
 +Turn in any code files that were modified for this lab. In addition, turn in a page with the following:
 +  - The WCET of each task in nanoseconds (with and without print statements if necessary).
 +  - The sum of all WCETs.
 +  - The smallest period of any task as discussed in section 11.4 of the book (you don't need the timer for this).
 +  - Will timer overrun occur in the worst-case situation? Why or why not?
 +  - How long did the lab take you? Other feedback?
lab_11.txt ยท Last modified: 2019/04/08 20:11 (external edit)