Pumpkin, Inc.

Pumpkin User Forums

time delay from OSSignalBinSem to OS_WaitBinSem

If you can't make Salvo do what you want it to do, post it here.

time delay from OSSignalBinSem to OS_WaitBinSem

Postby sunny » Tue Mar 25, 2003 1:02 am

Dear all,

1) The time delay from Signal Semaphore (from Task A) to Wait Semaphore (at Task B) is very long (687uS ar 4MHz). Is this normal?
How can I speed up the code (no increasing the clock)?

2) Why time duration for OSSignalBinSem has
"?" at manual page 468?

code:
void TaskToggle7( void )
{
LATBbits.LATB7 = 0; // RB7 start at 0

for(;;) {
OS_WaitBinSem( TOGGLE_EN_P,
OSNO_TIMEOUT,
TaskToggle7_1 );

LATBbits.LATB7 = !LATBbits.LATB7;

OSSignalBinSem( TOGGLE_EN_P );
}
}

void TaskToggle6( void )
{
LATBbits.LATB6 = 1; //RB6 start at 1

for(;;) {
OS_WaitBinSem( TOGGLE_EN_P,
OSNO_TIMEOUT,
TaskToggle6_1 );

LATBbits.LATB6 = !LATBbits.LATB6;

OSSignalBinSem( TOGGLE_EN_P );
}
}

void OSIdlingHook ( void )
{
;
}

void main( void )
{
TRISB = 0; //config PORT B to output

OSInit();

OSCreateTask( TaskToggle7, OSTCBP(1), 10 );
OSCreateTask( TaskToggle6, OSTCBP(2), 10 );

OSCreateBinSem( TOGGLE_EN_P, 1);

for (;;)
OSSched();
}


[This message has been edited by aek (edited March 25, 2003).]

sunny
 
Posts: 7
Joined: Mon Mar 24, 2003 12:00 am
Location: hong kong

Re: time delay from OSSignalBinSem to OS_WaitBinSem

Postby aek » Tue Mar 25, 2003 9:39 am

Hi Sunny.
quote:
1) The time delay from Signal Semaphore (from Task A) to Wait Semaphore (at Task B) is very long (687uS ar 4MHz). Is this normal?
How can I speed up the code (no increasing the clock)?
687 cycles looks about right. In your test application, here's what has to happen in those 687 cycles:

1) BinSem is signaled in TaskToggle7(). TaskToggle6() is the highest-priority task waiting the binSem.

2) TaskToggle7() waits the binSem. Since TaskToggle6() was already waiting the binsem, TaskToggle7() must be placed at the end of the queue of tasks that's waiting the binSem.

3) TaskToggle7() must return to the scheduler OSSched().

4) The scheduler loops.

5) The scheduler makes TaskToggle6() eligible to run.

6) TaskToggle6() runs, successfully waits the binSem.

Your test has extra cycles because after signaling the binSem in TaskToggle7() the task then waits (unsuccessfully) the binSem again.

If you want to get a better performance number, you should do something like this test:

code:
void TaskToggle6( void )
{
LATBbits.LATB6 = 0; //RB6 start at 0

for(;;) {
OS_WaitBinSem( TOGGLE_EN_P,
OSNO_TIMEOUT,
TaskToggle6_1 );

/* stop measuring here */
LATBbits.LATB6 = !LATBbits.LATB6;
}
}

void OSIdlingHook ( void )
{
;
}

void main( void )
{
TRISB = 0; //config PORT B to output

OSInit();

OSCreateTask( TaskToggle6, OSTCBP(1), 10 );

OSCreateBinSem( TOGGLE_EN_P, 0);

/* run TaskToggle6() once */
OSSched();

/* start measuring here */
OSSignalBinSem( TOGGLE_EN_P );

/* now TaskToggle6() will run again (because the */
/* binSem was signaled), and measure it in there.*/
OSSched();

/* finished with test */
for (;;);

}


In this test code, you are measuring the true time between signaling a binSem and the running of the task that's waiting the binSem to wake up.
quote:
2) Why time duration for OSSignalBinSem has "?" at manual page 468?
Chapter 9 is out of date, and should not be used for performance metrics. Please create your own test programs (like the one above) to get the most accurate results.

[This message has been edited by aek (edited March 25, 2003).]

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm


Return to Coding

Who is online

Users browsing this forum: No registered users and 2 guests

cron