• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Free FreeRTOS Course-Task Management
 

Free FreeRTOS Course-Task Management

on

  • 16,842 views

 

Statistics

Views

Total Views
16,842
Views on SlideShare
14,830
Embed Views
2,012

Actions

Likes
5
Downloads
3
Comments
2

51 Embeds 2,012

http://embedded-tips.blogspot.com 1092
http://www.embedded-tips.blogspot.com 246
http://embedded-tips.blogspot.in 243
http://www.embedded-tips.blogspot.in 81
http://embedded-tips.blogspot.de 32
http://embedded-tips.blogspot.ca 27
http://embedded-tips.blogspot.fr 24
http://www.embedded-tips.blogspot.de 24
http://embedded-tips.blogspot.tw 20
http://embedded-tips.blogspot.co.uk 19
http://embedded-tips.blogspot.com.au 16
http://embedded-tips.blogspot.kr 15
http://embedded-tips.blogspot.pt 12
http://embedded-tips.blogspot.com.es 11
http://embedded-tips.blogspot.ru 11
http://www.embedded-tips.blogspot.pt 10
http://embedded-tips.blogspot.com.br 10
http://www.embedded-tips.blogspot.com.au 9
http://embedded-tips.blogspot.com.ar 8
http://embedded-tips.blogspot.sg 8
http://www.embedded-tips.blogspot.co.uk 8
http://translate.googleusercontent.com 7
http://embedded-tips.blogspot.it 7
http://www.embedded-tips.blogspot.ca 7
http://www.embedded-tips.blogspot.it 6
http://www.embedded-tips.blogspot.fr 6
http://embedded-tips.blogspot.mx 6
http://embedded-tips.blogspot.fi 6
http://embedded-tips.blogspot.ro 5
http://www.embedded-tips.blogspot.se 3
http://embedded-tips.blogspot.se 3
http://embedded-tips.blogspot.dk 2
http://www.slideshare.net 2
http://www.embedded-tips.blogspot.com.es 2
http://www.embedded-tips.blogspot.sk 2
http://www.embedded-tips.blogspot.fi 2
http://www.embedded-tips.blogspot.com.ar 2
http://www.embedded-tips.blogspot.mx 2
http://www.embedded-tips.blogspot.gr 2
http://embedded-tips.blogspot.hk 2
http://www.embedded-tips.blogspot.co.at 2
http://www.embedded-tips.blogspot.com.br 1
http://embedded-tips.blogspot.co.at 1
http://www.embedded-tips.blogspot.ro 1
http://www.embedded-tips.blogspot.com.tr 1
http://embedded-tips.blogspot.co.il 1
http://embedded-tips.blogspot.no 1
http://embedded-tips.blogspot.jp 1
http://www.embedded-tips.blogspot.sg 1
http://embedded-tips.blogspot.nl 1
More...

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

12 of 2 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Hello sir,
    This is Mukesh. Sir, I have gone through all your RTOS ppt. They are excellent and very much helpful. Due to lack of proper Internet Connection I can't read it daily. so, I want if you can forward me ppt or pdf version of all your rtos ppt. Hoping for positive response. Thanking you sir.
    Are you sure you want to
    Your message goes here
    Processing…
  • Feel free to contact me @ amraldo@hotmail.com
    --
    Amr Ali Abdel-Naby
    Embedded Systems Developer
    www.embedded-tips.blogspot.com
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • * 07/16/96 * ##
  • Privileged mode * 07/16/96 * ##

Free FreeRTOS Course-Task Management Free FreeRTOS Course-Task Management Presentation Transcript

  • Introduction to FreeRTOS V6.0.5
  • About SwiftACT
    • A Technology services startup company
      • Under establishment
    • Areas of specialties:
      • Mobile telecommunication services development
      • Embedded systems development
    • Types of services:
      • Consultation
      • Managed services
      • Sourcing
      • Training
    Introduction to FreeRTOS V6.0.5 Amr Ali Abdel-Naby@2010
  • About Me
    • Graduated 2004
      • ECE, ASU: 5 yrs distinction
    • 6+ years in embedded systems development
      • SDLC, Apps, MW, DD, Porting, ...
    • 4+ years in SW engineering
      • PSP, CMMI, Systematic reuse, ...
    • 4+ years in SW testing
      • IBM certified, ISTQB certified, ...
    Introduction to FreeRTOS V6.0.5 Amr Ali Abdel-Naby@2010
  • Copyright
    • Materials in this course is the property of Amr Ali Abdel-Naby.
    • Reproduction or transmission of the materials outside [Customer Name] in any manner without the copyright owner permission is a law violation.
    • [Customer Name] is free to use this material as is within its head quarters for noncommercial uses.
    • Snapshots or trademarks used are retained to their original owners.
    Introduction to FreeRTOS V6.0.5 Amr Ali Abdel-Naby@2010
  • Course Objectives
    • After completing this course, you will:
      • Understand what is FreeRTOS
      • Experience different FreeRTOS services and APIs
      • Understand the porting process of FreeRTOS
    Introduction to FreeRTOS V6.0.5 Amr Ali Abdel-Naby@2010
  • Course Notes
    • I assume you are familiar with RTOS concepts.
    • I assume you know C.
    • I assume you know 80x86 architecture and assembly.
    • Ask any time.
    Introduction to FreeRTOS V6.0.5 Amr Ali Abdel-Naby@2010
  • Course References
    • http://www.freertos.org
    Introduction to FreeRTOS V6.0.5 Amr Ali Abdel-Naby@2010
  • Outline
    • Introduction to FreeRTOS
    • Lab 0: Getting Started
    • Kernel Structure
    • Lab 1: Kernel Structure
    • Task Management
    • Lab 2: Task Management
    • Queue Management
    • Lab 3: Queue Management
    • Semaphore/Mutex Management
    • Lab 4: Semaphore/Mutex Management
    • Co-routine Management
    • Lab 5: Co-routine Management
    • Advanced Features
    • Lab 6: Advanced Features
    • Porting FreeRTOS
    • Lab 7: Porting FreeRTOS
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Outline
    • Introduction to FreeRTOS
    • Lab 0: Getting Started
    • Kernel Structure
    • Lab 1: Kernel Structure
    • Task Management
    • Lab 2: Task Management
    • Queue Management
    • Lab 3: Queue Management
    • Semaphore/Mutex Management
    • Lab 4: Semaphore/Mutex Management
    • Co-routine Management
    • Lab 5: Co-routine Management
    • Advanced Features
    • Lab 6: Advanced Features
    • Porting FreeRTOS
    • Lab 7: Porting FreeRTOS
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Task C/Cs
    • Pros
      • Simple
      • No SW restriction on use
      • Supports full preemption
      • Fully priotrized
    • Cons
      • Stack/Task
        • High RAM usage
      • Take care of reentrancy
        • Specially with preemption
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Task States & Transitions Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5 Blocked Ready Running Suspended Event vTaskSuspend vTaskSuspend vTaskSuspend vTaskResume Blocking API
  • Task Priorities Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5 Priority Task 1 Task 2 Task 3 IDLE Task 2 … configMAX_PRIORITIES - 1 … tskIDLE_PRIORITY
  • Implementing a Task
    • The type pdTASK_CODE defines the type of the task.
    • Tasks should be of endless loop style.
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5 /* Endless Loop Task */ void vATaskFunction (void * pvParameters){ for(;;){ /* Task Code Here */ } }
  • Task’s Hook
    • A hook can be assigned to each task.
      • Used by application only to extend functionality
      • Kernel does not make use of it
      • Trace feature makes good use of it.
    • The type pdTASK_HOOK_CODE defines the type of the task hook.
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5 static portBASE_TYPE prvExampleTaskHook(void * pvParameter){ /* Perform some action - this could be anything from logging a value, updating the task state, outputting a value, etc. */ return 0; }
  • Idle Task
    • Created when the scheduler starts
    • Idle task free memory allocated by FreeRTOS that have been deleted.
      • If your application deletes tasks, make sure that idle task is not starved of CPU.
    • Application tasks can share idle task priority.
    • It has the least priority.
      • tskIDLE_PRIORITY
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Idle Task Hook
    • Called during each cycle of idle task
    • Extends Idle task functionality
      • Putting system into power-down mode
      • Should not call a blocking API
    • An alternative is to implement extra functionality as tasks.
      • More flexible but has higher RAM usage overhead
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5 void vApplicationIdleHook (void){ /* Application Hook Code */ }
  • Task Management APIs
    • They fall under 3 categories:
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5 Control vTaskDelay vTaskDelayUntil uxTaskPriorityGet vTaskPrioritySet vTaskSuspend vTaskResume xTaskResumeFromISR Creation xTaskCreate vTaskDelete Utilities tskIDLE_PRIORITY xTaskGetTickCount uxTaskGetNumberOfTasks vTaskList vTaskGetRunTimeStats vTaskStartTrace ulTaskEndTrace uxTaskGetStackHighWaterMark vTaskSetApplicationTaskTag xTaskGetApplicationTaskTag xTaskCallApplicationTaskHook
  • Creating a Task, xTaskCreate
    • portBASE_TYPE xTaskCreate(pdTASK_CODE pvTaskCode, const char * const pcName, unsigned short usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pvCreatedTask);
      • pvTaskCode: Pointer to the task entry function
      • pcName: A descriptive name for the task
        • Max length is defined by tskMAX_TASK_NAME_LEN.
        • Default is 16.
      • usStackDepth: The size of the task stack in stack entries
      • pvParameters: Pointer to the task parameter
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Creating a Task, xTaskCreate cont’d
    • portBASE_TYPE xTaskCreate(pdTASK_CODE pvTaskCode, const char * const pcName, unsigned short usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pvCreatedTask);
      • uxPriority: The task priority
        • Systems that include MPU support can optionally create tasks in a privileged (system) mode by setting bit portPRIVILEGE_BIT of the priority parameter.
          • e.g. ( 2 | portPRIVILEGE_BIT )
      • pvCreatedTask: Used to pass back a handle of the created task
      • Return value:
        • pdPASS if success
        • errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY if failure
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Deleting a Task, vTaskDelete
    • void vTaskDelete(xTaskHandle pxTask)
      • pxTask: The handle of the task to be deleted
        • If NULL, this will delete the calling task.
      • Note that the kernel deletes the kernel allocated data for the deleted task only by the idle task.
        • If your application task allocated memory, the application should clean it before deletion.
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Delaying a Task, vTaskDelay
    • void vTaskDelay(portTickType xTicksToDelay)
      • xTicksToDelay: The amount of time, in tick periods, that the calling task should block
      • Time is measured from the API call.
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Delaying a Task until a Specified Time, vTaskDelayUntil
    • void vTaskDelayUntil(portTickType * pxPreviousWakeTime, portTickType xTimeIncrement)
      • = vTaskDelay but with absolute reference
        • Can be used by cyclic tasks to ensure constant execution frequency
      • pxPreviousWakeTime: Pointer to a variable that holds the time at which the task was last unblocked
        • The variable must be initialized with the current time prior to its first use.
          • xTaskGetTickCount API or any value
        • The variable is automatically updated.
      • xTimeIncrement: The cycle time period
      • The task will be unblocked at time = pxPreviousWakeTime + xTimeIncrement
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Delaying a Task until a Specified Time, vTaskDelayUntil cont’d
    • void vTaskDelayUntil(portTickType * pxPreviousWakeTime, portTickType xTimeIncrement)
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5 void vTaskFunction(void * vParameters{ portTickType xLastWakeTime; const portTickType xFrequency = 10; // Initialise the xLastWakeTime variable with the current time. xLastWakeTime = xTaskGetTickCount(); for( ;; ){ // Wait for the next cycle. vTaskDelayUntil(&xLastWakeTime, xFrequency); // Perform action here. } }
  • Getting a Task’s Priority, uxTaskPriorityGet
    • unsigned portBASE_TYPE uxTaskPriorityGet(xTaskHandle pxTask)
      • pxTask: The handle of the task to be queried
        • If NULL, this will query the calling task.
      • Return value: The priority of pxTask
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Setting a Task’s Priority, vTaskPrioritySet
    • void vTaskPrioritySet(xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority)
      • pxTask: The handle of the task to which priority is set
        • If NULL, this will set the calling task.
      • uxNewPriority: The priority to which the task will be set
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Suspending a Task, vTaskSuspend
    • void vTaskSuspend(xTaskHandle pxTaskToSuspend)
      • pxTaskToSuspend : The handle of the task to suspend
        • If NULL, this will suspend the calling task.
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Resuming a Task, vTaskResume
    • void vTaskResume(xTaskHandle pxTaskToResume)
      • pxTaskToResume : The handle of the task to be readied
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Resuming a Task from ISR, vTaskResumeFromISR
    • portBASE_TYPE xTaskResumeFromISR(xTaskHandle pxTaskToResume)
      • = vTaskResume but can be called from ISR
      • Return value: pdTRUE if resuming the task should result in a context switch, otherwise pdFALSE
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Getting System Time, xTaskGetTickCount
    • portTickType xTaskGetTickCount(void)
      • Return value: The count of ticks since vTaskStartScheduler was called
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Getting Number of Tasks in the System, uxTaskGetNumberOfTasks
    • unsigned portBASE_TYPE uxTaskGetNumberOfTasks(void)
      • Return value: The number of tasks that the real time kernel is currently managing
        • Running task + ready tasks + blocked tasks + suspended tasks + deleted tasks but not yet freed by IDLE task
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Listing Tasks in the System, vTaskList
    • void vTaskList(signed char * pcWriteBuffer)
      • pcWriteBuffer: The buffer into which task list will be written, in ascii form.
        • 40 bytes per task should be sufficient.
        • Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or suspended ('S').
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Getting Tasks’ Run-Time Statistics, vTaskGetRunTimeStats
    • void vTaskGetRunTimeStats(signed char * pcWriteBuffer)
      • pcWriteBuffer: The buffer into which the execution times will be written
      • The application must also then provide definitions for:
        • portCONFIGURE_TIMER_FOR_RUN_TIME_STATS
        • portGET_RUN_TIME_COUNTER_VALUE
      • The counter should be at least 10 times the frequency of the tick count.
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Starting Tasks’ Trace, vTaskStartTrace
    • void vTaskStartTrace(signed char * pcBuffer, unsigned long ulBufferSize)
      • pcBuffer: The buffer into which the trace will be written
      • ulBufferSize: The size of pcBuffer in bytes
      • The trace will continue until either the buffer in full, or ulTaskEndTrace () is called.
      • The trace file is stored in binary format. A separate DOS utility called convtrce.exe is used to convert this into a tab delimited text file which can be viewed and plotted in a spread sheet.
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Ending Tasks’ Trace, ulTaskEndTrace
    • unsigned long ulTaskEndTrace(void)
      • Return value: The number of bytes that have been written into the trace buffer
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Getting Task’s Stack Watermark, uxTaskGetStackHighWaterMark
    • unsigned portBASE_TYPE uxTaskGetStackHighWaterMark(xTaskHandle xTask)
      • xTask: Handle of the task associated with the stack to be checked
      • Return value: The smallest amount of free stack space there has been (in bytes) since the task referenced by xTask was created.
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Hooking a Task, vTaskSetApplicationTaskTag
    • void vTaskSetApplicationTaskTag(xTaskHandle xTask, pdTASK_HOOK_CODE pxHookFunction)
      • xTask: The handle of the task to set a hook for
        • If NULL, this will tag the calling task.
      • pxHookFunction: Pointer to the task hook function
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Getting a Task’s Hook, xTaskGetApplicationTaskTag
    • pdTASK_HOOK_CODE xTaskGetApplicationTaskTag(xTaskHandle xTask)
      • xTask: The handle of the task to get its hook
      • Return value: The hook function assigned to the task
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Calling a Task Hook, xTaskCallApplicationTaskHook
    • portBASE_TYPE xTaskCallApplicationTaskHook(xTaskHandle xTask, void *pvParameter)
      • xTask: The handle of the task to call its hook
      • pvParameter: Pointer to the hook argument
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Outline
    • Introduction to FreeRTOS
    • Lab 0: Getting Started
    • Kernel Structure
    • Lab 1: Kernel Structure
    • Task Management
    • Lab 2: Task Management
    • Queue Management
    • Lab 3: Queue Management
    • Semaphore/Mutex Management
    • Lab 4: Semaphore/Mutex Management
    • Co-routine Management
    • Lab 5: Co-routine Management
    • Advanced Features
    • Lab 6: Advanced Features
    • Porting FreeRTOS
    • Lab 7: Porting FreeRTOS
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5
  • Lab2: Task Management
    • Please follow the instructions in the lab handout
    Amr Ali Abdel-Naby@2010 Introduction to FreeRTOS V6.0.5