'Frequenty Asked Questions for Lab 2'
Q. What exactly is the point of problem 2, the two files look the same to me?
Open the two files side by side. Try to find out how they send messages across the sender and reciever, where is the message stored. Look up what does mqd_t, mq_attr, mq_open etc and explain what do they achieve.
Q. Problem 3 looks like another variation of two_tasks.c file.
Yes, kinda. Though note there are two different semaphores involved and you get to chose a priority.
Q. What does it mean by "show me counters that increment in Host Shell dump"
As evidence, your program can print something every time it takes or gives a semaphore, e.g. a global counter. Also, the while(1) loops are not necessary, you can also do a while(my_global_var_to_break_loop), so that you can break the loop (by resetting the my_global_var_to_break_loop) and let the task die when you need to. Yes, you can change/view the global var value from the Host Shell, it helps in debugging programs too.
Q. What is taskSwitchHookAdd / Delete do?
Read up on them at <WindriverInstalDir>\docs\extensions\eclipse\plugins\com.windriver.ide.doc.vxworks\vxworks_kernel_api_reference_6.5\taskHookLib.html
Q. My target reboots when I add my taskSwitch?
You didn't read the documentation carefully. As it says "User-installed switch hooks are called within the kernel context. Therefore, switch hooks do not have access to all VxWorks facilities. " For example, calling a semTake will cause unexpected behavior just like a printf (yes, it's tempting to put one in there).
Q. Do I have to use PIT, can't I just use tickGet?
Yes, you have to use PIT. tickGet() does not have a high enough resolution to be used for this lab. Though you can start with tickGet() and have your frame work up and running.
Q. What is meant by "preempt" and "dispatch" counts?
Every time a particular task is passed to your switch hook as the WIND_TCB *pOldTcb, you may consider this a preemption and increment your preempt count for this particular task. Every time this task is passed to your switch hook as the WIND_TCB *pNewTcb, you may consider this a dispatch. Note that by strict definition, to know for sure that a task is being preempted (and not finished with execution) you would need to consult the status member of the WIND_TCB structure.(courtesy Dan Walkes)
Q. What is WIND_TCB?
It's an vxworks internal structure defined in taskLib.h file. Can you find the file on the system?
Q. I can't seem to find the task id in the wind_tcb structure. How do I know if the task pre-empted or dispatched is my task?
The pointer itself is the id. It says so in the documentation of taskLib "The tid (task ID) argument is simply the address of the WIND_TCB for the task (the taskInit( ) pTcb argument), cast to an integer:"
Q. My dispatch / pre-empt counter, system viewer do not make sense, what am I doing wrong? Or My system viewer shows many task switches, but my counter(s) is updated only a couple of time
Look a the system viewer, is the system spending most of it's time in idle? Though idle shows up as a task line, it is NOT a task. The taskSwitch function is NOT called when a system goes from a task X to idle or back. Maybe you can come up with a clever way to never let the system go idle? (Hint: A very low priority (say 200) task that does nothing useful, e.g. while(1); ) If you don't take care of this, your numbers will be wacky, especially for last question where tNetTask is being profiled.)
Q. What is meant by average Dispatch time?
The average dispatch time (execution time per dispatch) calculated by considering the average run time (time between last dispatch and current preempt) averaged across all executions of the task in 30 seconds.(courtesy Dan Walkes)
You might wanna first go with just calculating number of time tNetTask tasks gets pre-empted or dispatched for a couple of seconds, then in thirty seconds, then figure out how you may capture the execution time per dispatch and calculate it's average.
A lot of time students start using global static size arrays with no check on index and run out of memory, causing the target to crash. If you see your target reboots, make sure you are not accessing memory you shouldn't have.
Do not for forget to add units (msec, usec) if you are printing out time or in your report.
This page is last updated on October 28, 2008