Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

a bug in vTaskResume

Posted by ares.qi on June 22, 2005
When we are in a SuspendAll state and call vTaskResume, we should put the TaskToResume on xPendingReadyList instead of pxReadyTasksLists

so at line 834 in task.c

taskENTER_CRITICAL();
{
xYieldRequired = ( pxTCB->uxPriority >= pxCurrentTCB->uxPriority );
vListRemove( &( pxTCB->xGenericListItem ) );
prvAddTaskToReadyQueue( pxTCB );
}
taskEXIT_CRITICAL();

====== can be change to =======>>>>

taskENTER_CRITICAL();
{
if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE )
{
xYieldRequired = ( pxTCB->uxPriority >= pxCurrentTCB->uxPriority );
vListRemove( &( pxTCB->xGenericListItem ) );
prvAddTaskToReadyQueue( pxTCB );
}
else
{
vListInsertEnd( ( xList * ) &( xPendingReadyList ), &( pxUnblockedTCB->xEventListItem ) );
}

}
taskEXIT_CRITICAL();

RE: a bug in vTaskResume

Posted by Richard on June 22, 2005
Thanks for your feedback.

From my first look it seems you are right here. When the scheduler is locked, cases where events ready are task are covered, but there is nothing stopping an application readying a task. Seems to be a whole in the tests that need filling.

Thanks,
Richard.

RE: a bug in vTaskResume

Posted by Nobody/Anonymous on June 22, 2005
think here calling TaskRemume when the scheduler is locked will cause the resumed task to be added to the ready list but no yield will happen. the task switch will happen next tick or next call to yield. This means not to serious. task will run again but possibly in wrong sequence.

RE: a bug in vTaskResume

Posted by Richard on June 22, 2005
I have added the following text to the "known issues with current build" list (on the FreeRTOS.org WEB site) and in a bug tracker.

"The functions vTaskSuspendAll() and xTaskResumeAll() are available to suspend and resume the scheduler. The functions vTaskSuspend() and vTaskResume() are available to suspend and resume individual tasks.

If the scheduler is not suspended when a call to vTaskResume() is made, the task being resumed will start to execute immediately if it's priority is higher than the currently executing task.

In the case where the scheduler is suspended when a call to vTaskResume() is made - if the task being resumed has a priority higher than the currently executing task then it should start to run immediately upon the scheduler being unsuspended.

However, in the second case the task will not start executing when the scheduler is unsuspended, but only following the next RTOS tick or the next call to a yielding function"

RE: a bug in vTaskResume

Posted by ares.qi on June 22, 2005
>This means not to serious. task will run again but possibly in wrong sequence.

yes, you are right.

but , if we put the higher priority resuming task in xPendingReadyList , after we call xTaskResumeAll, this higher priority task can be schedued in correct sequence.

i think it's better

RE: a bug in vTaskResume

Posted by ares.qi on June 22, 2005
i find vTaskPrioritySet() may be have the same problem when scheduler is locked.

in addition , there is also a optimisation in vTaskPrioritySet()

in current vTaskPrioritySet(), taskYIELD() will be called every time no matter it's necessary. we can set a flag portBASE_TYPE xYieldRequired .

xYieldRequired = pdFALSE;
.......
if (pxTask == pxCurrentTCB) && (uxNewPriority < pxCurrentTCB->uxPriority) // if lower the current task's priority
__xYieldRequired = pdTRUE;
else if (pxTask != pxCurrentTCB) && (uxNewPriority > pxCurrentTCB->uxPriority) // if upper another task's priority and higher than the current task's priority
__xYieldRequired = pdTRUE;
......
if (xYieldRequired)
__taskYIELD();

RE: a bug in vTaskResume

Posted by Richard on June 29, 2005
Fixed in V3.2.0!


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists