Questions 2,3,and 4
You may assume the array of tasks passed into this function is in priority order. In other words, the *tid values will all have priorities starting with 1 and ending with Ntasks, from highest to lowest priority.
These functions may be downloaded, executed and debugged on the targets in the lab. Alternatively, you may use the simulator or simply use gcc.
For some hints on how to interpret and understand the completion time test as shown in the Real Time Embedded Componets and Systems text, see this link.
Comon Questions:
Q- My driver function does XXXX is that OK?
A- I don't care how you implement your driver function, as long as it is sufficent to test your code. The driver is mostly for your purposes. I will use my own driver to test your functions as specified in the problem. Make sure you follow the prototypes listed in the problem for your function declarations. It is helpful if you put your driver code in one .c file and functions in another. That way I can link your functions file with my driver file to test. Please submit both for grading.
Questions 8 and 9
To re-use this function in questions 9-11, it is helpful to write it such that any global variables are not accessed directly by the function. In other words, two of these functions should be able to run with seperate instances of each other and not corrupt one another's execution.
Also, you need to be careful about calling parameters. Take a look at the taskSpawn function and note the type of parameters which can be passed to the function. Then consider the size of variable you will need for a large number of Fibbonacci terms. It may be helpful to pass a pointer to a global variable of sufficient size to specify the number of terms to compute in the sequence.
To make the function more re-usable in questions 9-11, it may be nice not to print the result directly in your function. One way to print the result outside of your function would be to pass a pointer to a location to store the result. You also may need to consider the priority of the function spawning the task to determine if the Fibonnacci function will complete before or after the spawning function. See taskPrioritySet and taskIdSelf to manipulate calling function priority if necessary.
You might note that an actual Fibbonacci number at the sequences necessary to give desired execution times of 10 and 20ms would require a number larger than 4 bytes as storage. It is fine to use a 4 byte storage value and ignore the variable overflow. We are not concerned with the actual number, we are just using the Fibbonacci routine as a loading function to test scheduling theory.
Comon Pitfalls to Avoid:
1) Do not use printf inside your fibbonacci function. This will make your function timing unpredictable. Use an external function to spawn your fibbonacci calculation function and print the value from this function.
2) Do not try to save every number in the fibbonacci sequence... or if you do make sure you have buffering necessary to do so. It is not required that you save (or show) every number, you just want to calculate the Nth term. All other values are intermediate.
3) If you are unable to download your windview capture (the program hangs), you can suspect that the CPU on the target is most likely overloaded. This is most likely because your code has run amok. Look for things like infite loops, uninitialized pointers, or exceeded array bounds. Think about the size of variables declared in the function and the stack size specified by taskSpawn. Another possibility is that someone left a task running on this target that is bogging it down. It is a good idea to always restart the target before you try your code the first time.
Question 11
A good way to setup this test would be to call a test function that spawns two different task.. a high and low priority Fibbonacci function spawning task. The high and low priority tasks would spawn the Fibbonacci functions at the given rate using delays between taskSpawn calls. Think hard about the priority of each of these functions and the priority of the spawned Fibbonacci computing functions. How long should the delays be between function spawns?
Use your knowledge of scheduling theory to determine the number of times each of the low priority and high priority functions should be spawned in order to adaquately illustrate system scheduling success or failure. Success would mean that there should be idle execution time during the execution of these tasks. Failure would mean that these tasks would overlap and miss their deadlines. Either of these scenarios will be easy to show using a Windview plot.
Refer to the "Scheduling Point Test" section in the Real Time Embedded Components and Systems Online text for more information about our friends Lehoczky, Shah, and Ding.