file list.c vListRemove

nobody wrote on Monday, February 20, 2006:

Hello,

I]in the file list.c in xListRemove, is there a mistake at the end :
void vListRemove( xListItem *pxItemToRemove )
{
xList * pxList;

    pxItemToRemove->pxNext->pxPrevious = pxItemToRemove->pxPrevious;
    pxItemToRemove->pxPrevious->pxNext = pxItemToRemove->pxNext;
   
    /* The list item knows which list it is in.  Obtain the list from the list
    item. */
    pxList = ( xList * ) pxItemToRemove->pvContainer;

    /* Make sure the index is left pointing to a valid item. */
    if( pxList->pxIndex == pxItemToRemove )
    {
        pxList->pxIndex = pxItemToRemove->pxPrevious;
    }

    pxItemToRemove->pvContainer = NULL;
    ( pxList->uxNumberOfItems )–;
}

Shouldn’t it be :
    ( pxList->uxNumberOfItems )–;
    pxItemToRemove->pvContainer = NULL;

II]I’m trying to use the vTaskDelayUntil :
I have 3 tasks
- task 1 : priority 1 and it is resuming task 2
- task 2 : priority 2 and it is itself suspending
- task 3 : using vTaskDelayUntil like in FreeRTOS example

and it is scheduling like this
task 3 wake up + sleeping
task 2
task 1
task 2
task 1
task 2
task 3 wake up by timer + sleeping
task 1
task 1

task 3 wake up by timer + sleeping
task IDLE …

I don’t understand why it is 'killing" the other task : the value of uxNumberOfItems for the
pxReadyTasksLists[2] & [3] became 0 ???

chris

nobody wrote on Monday, February 20, 2006:

> Shouldn’t it be :
> ( pxList->uxNumberOfItems )–;
> pxItemToRemove->pvContainer = NULL;

Looks like you have just swapped the last two lines around, or have I missed something?  I don’t think it makes any difference which way around the lines are unless you have spotted something otherwise.

> II]I’m trying to use the vTaskDelayUntil :
> I have 3 tasks
> - task 1 : priority 1 and it is resuming task 2
> - task 2 : priority 2 and it is itself suspending
> - task 3 : using vTaskDelayUntil like in FreeRTOS example
>
> and it is scheduling like this
> task 3 wake up + sleeping
> task 2
> task 1
> task 2
> task 1
> task 2
> task 3 wake up by timer + sleeping
> task 1
> task 1
> …
> task 3 wake up by timer + sleeping
> task IDLE …
>
> I don’t understand why it is 'killing" the other task : the value of uxNumberOfItems
> for the
> pxReadyTasksLists[2] & [3] became 0 ???

You don’t say what priority task 3 is, but don’t think this matters.  Your question is what happens to task 2 when task 1 runs twice in a row?

pxReadyTasksLists[2] and [3] will only contain data when the tasks are in the ready state, so it might be ok that there is nothing in them.

Can you provide an outline of the structure of your tasks?

nobody wrote on Monday, February 20, 2006:

for the first question, you’re right I mistake with pointers.
For the second : task 3 is priority 3 and task 1 is my low priority task in which there is always something to do
static void task1( void *pvParameters )
{
    ( void ) pvParameters;
    for( ;; )
    {
    //there is always something : polling + TaskResume(Task2) so pxReadyTasksLists[1].uxNumberOfItems must be always 1
            
    }
}

static void task2( void *pvParameters )
{
    ( void ) pvParameters;
    for( ;; )
    {
    //code + TaskSuspend(NULL)
            
    }
}

static void task3( void *pvParameters )
{
portTickType xDelayPeriod = 100;
portTickType xLastWakeTime;

    ( void ) pvParameters;

    xLastWakeTime = xTaskGetTickCount();

    for( ;; )
    {
        vTaskDelayUntil( &xLastWakeTime, xDelayPeriod );
//code
    }
}

I understand pxReadyTasksLists[2].uxNumberOfItems can be 0 because I’m suspending it but for the task1 it must be always 1 but in my case this task is not working anymore as I wrote before.

chris

nobody wrote on Monday, April 17, 2006:

Hey all,

I might have encountered the same problem, related to vListRemove. It seems to me that the problem is related to vTaskResumeAll who remove ready task from EventList without checking if it’s actually listed in any EventList. This is the case with vTaskDelay or vTaskDelayUntil.

I posted this problem today (17/04/06)
Still seeking solution.

Ami.

nobody wrote on Monday, April 17, 2006:

See: https://sourceforge.net/forum/message.php?msg_id=3690124