Tasks stop running

phil4321 wrote on Thursday, November 29, 2007:

Hi All,

I have had a system running successfully with several task running with the *pvParameters set to Null, as I did not need to pass in any variables.

I am upgrading the code so that I can check if the tasks are still running by incrementing a counter passed into the task ‘usTaskCheck[ 1 ]’ (I have used the examples given in the demo app’s)

The problem I have is I configure the code as shown below and for some reason all the other tasks in the system stop running. The vComTxTask1 still runs as configured.

Any ideas or help would be appreciated,

Thanks,

Phil

xTaskCreate( vComTxTask1, ( const signed portCHAR * const ) "COMTx", comSTACK_SIZE, ( void * ) &( usTaskCheck[ 1 ] ), RabbitPortSettings.uxSerPortPriority, ( xTaskHandle * ) NULL );

static void vComTxTask1( void *pvParameters )
{
  portTickType xRabbitTxTickPeriod = RABBIT_TX_TICK_PERIOD; 
  portTickType xRabbitTxTickTime;
 
  volatile unsigned portSHORT *pusTaskCheckVariable; 

  pusTaskCheckVariable = ( unsigned portSHORT * ) pvParameters;

  for( ;; )
  {
   
    vTaskDelayUntil( &xRabbitTxTickTime, xRabbitTxTickPeriod ); 
    vRabbitTxMessageSM(); 
   
    ( *pusTaskCheckVariable )++; //Tick the task counter
               

  }//end of for
    
 
}

rtel wrote on Thursday, November 29, 2007:

There is nothing obviously wrong with your code, but I I’m not sure which port you are using.  Is it running on a Rabbit Semiconductors processor?  If so where did you get the port from, and if not, which processor are you using it on.  Also which compiler are you using?

Regards.

phil4321 wrote on Friday, November 30, 2007:

Hi Richard,

I am using the ARM STR712 controller to communicate with a Rabbit processor. I am using the IAR development tools and compiler and currently version V4.2.1 of FreeRTOS.

Below is the original way I had written the task function. Most of my task function have been written using the portTASK_FUNCTION definition. When I hit on this problem I tried defining the function as ‘static void vComTxTask( void *pvParameters )’ would this cause the problem.

I find it a bit strange that the vComTxTask function runs correct but any other task in my system stops running. If I configure the code as below the system tasks start running again.

I can confirm that the other tasks in my system are been initialized correct. I have another task running in the same class as the function below ‘vComRxTask’ and this runs correct. So all tasks are running correct in the class I defined the pvParameters in, outside of this they don’t get called?

Regards,

Phil

  xTaskCreate( vComTxTask, ( const signed portCHAR * const ) "COMTx", comSTACK_SIZE, NULL , RabbitPortSettings.uxSerPortPriority+1, ( xTaskHandle * ) NULL );

static portTASK_FUNCTION( vComTxTask, pvParameters )
{
  portTickType xRabbitTxTickPeriod = RABBIT_TX_TICK_PERIOD; 
  portTickType xRabbitTxTickTime;
 
/* Just to stop compiler warnings. */
  ( void ) pvParameters;

  for( ;; )
  {
    vTaskDelayUntil( &xRabbitTxTickTime, xRabbitTxTickPeriod ); 
    vRabbitTxMessageSM(); 

  }//end of for
  
}//endoffunction

rtel wrote on Friday, November 30, 2007:

Curious.  Is the COM task the highest priority task?  If so, it not blocking for some reason could cause the other tasks to be starved out.

Have you tried commenting out the line:
( *pusTaskCheckVariable )++; //Tick the task counter

just in case the pointer value is invalid, and writing to it is causing some corruption.

Regards.

phil4321 wrote on Sunday, December 02, 2007:

Hi,

I had tried commenting out the ( *pusTaskCheckVariable )++; and had determined that this was not the problem.

I took a look at the task priority’s and the tasks that had not been running where lower than the one’s that are running such as the ‘vComTxTask1’ tasks. I made all the tasks that had not been running correct equal to the ‘vComTxTask1’ priority (set to 2) and they started running correct.

I still have some higher priority tasks running in the system that don’t seem to effect the running of the lower tasks.

I am curious to why when I start using the pvParameters I started to get the problems with tasks not running. Is it because it takes a bit more system time when using the pvParameters.

I would be interested in any techniques used to monitor the amount of resource/time each task is using and if it will cause a problem hogging the systems resources. In the past with a simpler (home made) OS I have often toggled some IO pins and measured the time each task is using to get a feel of what is happening in the system, unfortunately I don’t have the luxury of a scope at the moment. Any hints and tips on setting up priority’s would be useful.  

Thanks for the support,

Phil

phil4321 wrote on Monday, December 03, 2007:

Hi,

I fixed the problems with the tasks stopping running, this has now caused the co-routine to stop running, I have tried changing the priority level for the co-routine this has had no effect. If I don’t use the pvParameters and make this equal to null when I configure the tasks they co-routine runs as expected.

Thanks,

Phil