Skip to Content
Hands-On RTOS with Microcontrollers
book

Hands-On RTOS with Microcontrollers

by Brian Amos
May 2020
Intermediate to advanced
496 pages
13h 54m
English
Packt Publishing
Content preview from Hands-On RTOS with Microcontrollers

Deleting a task from another task

In order to delete a task from another task, blueTaskHandle needs to be passed to xTaskCreate and its value populated. blueTaskHandle can then be used by other tasks to delete BlueTask, as shown here:

TaskHandle_t blueTaskHandle;int main(void){    HWInit();    assert_param( xTaskCreate(BlueTask, "BlueTask", STACK_SIZE,                  NULL, tskIDLE_PRIORITY + 1, &blueTaskHandle) ==                   pdPASS);    xTaskCreateStatic( RedTask, "RedTask", STACK_SIZE, NULL,                       tskIDLE_PRIORITY + 1, RedTaskStack,                       &RedTaskTCB);    vTaskStartScheduler();    while(1);}void RedTask( void* argument ){    vTaskDelete(blueTaskHandle);}

The actual code in main.c results in the blue LED blinking for ~ 1 second before being deleted by RedTask. At this point, the blue LED stops ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On RTOS with Microcontrollers - Second Edition

Hands-On RTOS with Microcontrollers - Second Edition

Jim Yuill, Penn Linder

Publisher Resources

ISBN: 9781838826734Supplemental Content