Download INtime 4.0 Quick Start Guide

Transcript
14) To easily identify the three threads in our process from within
INtime Explorer and INscope we can add their names to the
MultiThread process object directory.
Add the following code to MultiThread.c, the file that contains
main().
CatalogRtHandle(NULL_RTHANDLE,strInit.hPollThread1,"PollThread1");
CatalogRtHandle(NULL_RTHANDLE,strInit.hPollThread2,"PollThread2");
CatalogRtHandle(NULL_RTHANDLE,strInit.hPollThread3,"PollThread3");
// indicate that initialization has finished
strInit.state = INIT_DONE;
15) PollThread1.c and PollThread2.c have nearly identical code.
Make the following modifications to each of these files and be
sure the variable specified after the TODO line matches the
thread number.
void
PollThread1(void)
{
#ifdef _DEBUG
printf("PollThread1 started\n");
#endif
while (1)
{
if (!knWaitForRtAlarmEvent(hAlarmPollThread1,
KN_WAIT_FOREVER))
Fail("Cannot wait for alarm PollThread1");
//#ifdef _DEBUG
//
printf("PollThread1 waking up\n");
//#endif
// TODO: do what has to be done every 5000 microseconds
++dwPollThread1;
}
}
Note: The code immediately following the while(1)
statement will differ for each thread, as a function of the
time interval and the sleep method specified when you used
the wizard to generate the template code. Also, unlike the
previous examples, in this example remove (or comment
out) the #ifdef _DEBUG lines of code inside the while(1)
statement, we do not want the printf() statements to
interfere with the output and timing of these threads.
16) PollThread3.c contains more code than the prior two. Make the
following modifications to this file; again, make sure that the
number specified in the putchar('#') line matches the thread
number.
void
{
PollThread3(void)
int i = 0;
int x = 0;
page 30 of 46
Copyright © 2005-2009, TenAsys Corporation