This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

6437 semaphore

Hi.

On 6437 EVM  the following code not working properly.

/*
 * ======== main ========
 */
Void main() {

    LOG_printf(&trace,"Start of semaphore. \n");

    return;
}

 


void uartTSK(void)
{
  while(1)
  {
 SEM_pend(&sems,SYS_FOREVER);
 LOG_printf(&trace, "TSK0 Start");
//    TSK_yield();
    LOG_printf(&trace, "TSK0 Main");
//    TSK_yield();
    LOG_printf(&trace, "TSK0 Finish");
// TSK_yield();
 SEM_post(&sems);
  }
}


/*
 * ======== video_preview ========
 */
void video_preview(void)
{
  while(1)
  {
 SEM_pend(&sems,SYS_FOREVER);
 LOG_printf(&trace, "TSK1 Start");
//    TSK_yield();
    LOG_printf(&trace, "TSK1 Main");
//    TSK_yield();
    LOG_printf(&trace, "TSK1 Finish");
    LOG_printf(&trace,"Start of semaphore. \n");
// TSK_yield();
 SEM_post(&sems);
  }
}

sems is set to 1.

video_preview task priority 4.

uartTSK task priority 3.

The output of trace is .

30766089 TSK1 Start

30766090 TSK1 Main

30766091 TSK1 Finish

30766092 Start of semaphore.

30766093 TSK1 Start

30766094 TSK1 Main

30766095 TSK1 Finish

30766096 Start of semaphore.

30766097 TSK1 Start

30766098 TSK1 Main

30766099 TSK1 Finish

30766100 Start of semaphore.

30766101 TSK1 Start

30766102 TSK1 Main

30766103 TSK1 Finish

30766104 Start of semaphore.

And so on ....

It looks like the  SEM_post(&sems);  is not working .

Please Advise.
 

 

  • Hi,

    The video_preview TSK is higher priority, so it runs first upon start-up. It gets the SEM (since the count was 1). It then posts the SEM. But then it wraps around and keeps doing the same thing. The uartTSK TSK never gets to run since it is lower priority and the video_preview TSK never blocks on anything. Even if the TSK_yields were uncommented, the behavoir would be the same. TSK_yield only yields to a TSK of the same priority (a higher priority would have bumped the lower one out).

    Try putting a TSK_sleep in the video_preview. This will allow the lower priority TSK to run. (The TSK_sleep is just an experiment to show the functionality, I'm not sure what you should really do since I don't know the goal of the app).

    Todd