1. Trang chủ
  2. » Cao đẳng - Đại học

Introduction to uCOS II v2 6 m3

23 247 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 23
Dung lượng 380,5 KB

Nội dung

Introduction to uCOS-II V2.6 About SwiftACT • A Technology services startup company o Under establishment • Areas of specialties: o o Mobile telecommunication services development Embedded systems development • Types of services: o o o o Consultation Managed services Sourcing Training Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 About Me • Graduated 2004 o ECE, ASU: yrs distinction • 5+ years in embedded systems development o SDLC, Apps, MW, DD, Porting, • 3+ years in SW engineering o PSP, CMMI, Systematic reuse, • 3+ years in SW testing o IBM certified, ISTQB certified, Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Copyright • Materials in this course is the property of Amr Ali Abdel-Naby • Reproduction or transmission of the materials in any manner without the copyright owner permission is a law violation Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Course References • MicroC/OS-II The Real-Time Kernel, 2nd Edition, by Jean J Labrosse Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Outline • • • • • • • • • • Introduction to µC/OS-II Kernel Structure Task Management Time Management Semaphore Management Mutual Exclusion Semaphores Event Flag Management Message Mailbox Management Message Queue Management Memory Management Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Outline • • • • • • • • • • Introduction to µC/OS-II Kernel Structure Task Management Time Management Semaphore Management Mutual Exclusion Semaphores Event Flag Management Message Mailbox Management Message Queue Management Memory Management Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Task Management APIs • Available task operations are: o o o o o o o o o Task creation Stack checking Task deletion Requesting a task deletion Changing a task’s priority Task suspension Task resumption Getting task’s info Task name manipulation Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Creating a Task, OSTaskCreate INT8U OSTaskCreate (void (*task)(void *pd), void *pdata, OS_STK *ptos, INT8U prio) • • • • • task: A pointer to the task's code pdata: A pointer to an optional data area which can be used to pass parameters to the task when the task first executes ptos: A pointer to the task's top of stack prio: The task's priority Return value: o o o No error Priority exist Invalid priority Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Creating a Task, OSTaskCreateExt INT8U OSTaskCreateExt (void (*task)(void *pd), void *pdata, OS_STK *ptos, INT8U prio, INT16U id, OS_STK *pbos, INT32U stk_size, void *pext, INT16U opt) • • • • • • OSTaskCreate + id: Task’s ID, not used currently pbos: A pointer to the task's bottom of stack stk_size: A pointer to the task's top of stack pext: A pointer to a user supplied memory location which is used as a TCB extension opt: Additional information (or options) about the behavior of the task Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Task Stacks • Each task has its own stack o It must be:  Declared as OS_STK  Consistent & contiguous memory • It can be allocated static • Or dynamic OS_STK MyTaskSTack[stack_size]; OS_STK *pstk; pstk = (OS_STK*)malloc(stack_size); Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Task Stacks cont’d • Dynamic allocation may suffer from fragmentation KB A (1KB) (1KB) B (1KB) B (1KB) C • Your code should support(1KB) stacks that(1KB) grow in either direction OS_STK TaskStack[stack_size]; #ifdef OS_STK_GROWTH == OSTaskCreate(task, pdata, &TaskStack[0], prior); #else OSTaskCreate(task, pdata, &TaskStack[stack_size-1], prior); #endif Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Stack Checking • Assume stack is cleared at the beginning Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Stack Checking, OSTaskStkChk INT8U OSTaskStkChk (INT8U prio, OS_STK_DATA *pdata) • • • prio: The task priority pdata: A pointer to stack data Return value: o o o o No error Invalid priority Task does not exist Task options does not support stack checking Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Deleting a Task, OSTaskDel INT8U OSTaskDel (INT8U prio) • • prio: Priority of the task to delete Return value: o o o o o No error Invalid priority Task does not exist Deleting idle task Deleting a task from ISR Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Requesting to Delete a Task • A deleted task should delete its resources as well o To avoid leaks • The OSTaskDelReq is the keyword void RequestorTask(void * pdata){ if(TasktoBeDeleted needs to be deleted){ while(OSTaskDelReq(Task_TO_DEL_PRIO) != OS_TASK_NOT_EXIST) OSTimeDly(1); } void TaskToBeDeleted(void * pdata){ } if(OSTaskDelReq(OS_PRIO_SELF) == OS_TASK_DEL_REQ){ Release any resources & de-allocate any dynamic memory; OS_DEL(OS_PRIO_SELF); } else{ /* Application code*/ } } Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Requesting to Delete a Task, OSTaskDelReq INT8U OSTaskDelReq (INT8U prio) • • prio: Priority of the task to be deleted Return value: o o o o o No error Invalid priority Task does not exist Deleting idle task Deleting a task from ISR Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Changing a Task’s Priority, OSTaskChangePrio INT8U OSTaskChangePrio (INT8U oldprio, INT8U newprio) • • • oldprio: The old priority newprio: The new priority Return value: o o o o o No error Invalid priority Task to change priority does not exist New priority already exists Changing IDLE priority Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Resuming a Task, OSTaskResume INT8U OSTaskResume (INT8U prio) • • prio: The priority of the task to resume Return value: o o o o No error Invalid priority Task is not suspended Task does not exist Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Suspending a Task, OSTaskSuspend INT8U OSTaskSuspend (INT8U prio) • • prio: The priority of the task to suspend Return value: o o o o No error Invalid priority Suspending idle task Task does not exist Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Getting Info About a Task, OSTaskQuery INT8U OSTaskQuery (INT8U prio, OS_TCB *pdata) • • • prio: The priority of the task to obtain its information pdata: A pointer to returned task information Return value: o o o No error Invalid priority Task does not exist Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Getting a Task’s Name, OSTaskNameGet INT8U OSTaskNameGet (INT8U prio, char *pname, INT8U *err) • • • prio: The priority of the task that you want to obtain its name pname: A pointer to an ASCII string that will receive the name of the task err: o o o o • No error Task does not exist A null pointer is passed for the name Invalid priority Return value: Length of the string Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Naming a Task, OSTaskNameSet void OSTaskNameSet (INT8U prio, char *pname, INT8U *err) • • • prio: The priority of the task that you want to assign a name to pname: A pointer to an ASCII string that contains the name of the task err: o o o o o No error Task does not exist Name too long A null pointer is passed for the name Invalid priority Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 [...]... Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Deleting a Task, OSTaskDel INT8U OSTaskDel (INT8U prio) • • prio: Priority of the task to delete Return value: o o o o o No error Invalid priority Task does not exist Deleting idle task Deleting a task from ISR Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Requesting to Delete a Task • A deleted task should delete its resources as well o To avoid leaks... priority Task to change priority does not exist New priority already exists Changing IDLE priority Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Resuming a Task, OSTaskResume INT8U OSTaskResume (INT8U prio) • • prio: The priority of the task to resume Return value: o o o o No error Invalid priority Task is not suspended Task does not exist Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Suspending... pdata, &TaskStack[stack_size-1], prior); #endif Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Stack Checking • Assume stack is cleared at the beginning Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Stack Checking, OSTaskStkChk INT8U OSTaskStkChk (INT8U prio, OS_STK_DATA *pdata) • • • prio: The task priority pdata: A pointer to stack data Return value: o o o o No error Invalid priority Task... Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Naming a Task, OSTaskNameSet void OSTaskNameSet (INT8U prio, char *pname, INT8U *err) • • • prio: The priority of the task that you want to assign a name to pname: A pointer to an ASCII string that contains the name of the task err: o o o o o No error Task does not exist Name too long A null pointer is passed for the name Invalid priority Amr Ali Abdel-Naby@2010 Introduction. .. RequestorTask(void * pdata){ if(TasktoBeDeleted needs to be deleted){ while(OSTaskDelReq(Task _TO_ DEL_PRIO) != OS_TASK_NOT_EXIST) OSTimeDly(1); } void TaskToBeDeleted(void * pdata){ } if(OSTaskDelReq(OS_PRIO_SELF) == OS_TASK_DEL_REQ){ Release any resources & de-allocate any dynamic memory; OS_DEL(OS_PRIO_SELF); } else{ /* Application code*/ } } Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Requesting... Return value: o o o No error Invalid priority Task does not exist Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Getting a Task’s Name, OSTaskNameGet INT8U OSTaskNameGet (INT8U prio, char *pname, INT8U *err) • • • prio: The priority of the task that you want to obtain its name pname: A pointer to an ASCII string that will receive the name of the task err: o o o o • No error Task does not exist... prio) • • prio: The priority of the task to suspend Return value: o o o o No error Invalid priority Suspending idle task Task does not exist Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Getting Info About a Task, OSTaskQuery INT8U OSTaskQuery (INT8U prio, OS_TCB *pdata) • • • prio: The priority of the task to obtain its information pdata: A pointer to returned task information Return value:... Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Requesting to Delete a Task, OSTaskDelReq INT8U OSTaskDelReq (INT8U prio) • • prio: Priority of the task to be deleted Return value: o o o o o No error Invalid priority Task does not exist Deleting idle task Deleting a task from ISR Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Changing a Task’s Priority, OSTaskChangePrio INT8U OSTaskChangePrio... OS_STK  Consistent & contiguous memory • It can be allocated static • Or dynamic OS_STK MyTaskSTack[stack_size]; OS_STK *pstk; pstk = (OS_STK*)malloc(stack_size); Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Task Stacks cont’d • Dynamic allocation may suffer from fragmentation 3 KB A (1KB) (1KB) B (1KB) B (1KB) C • Your code should support(1KB) stacks that(1KB) grow in either direction OS_STK... ASCII string that contains the name of the task err: o o o o o No error Task does not exist Name too long A null pointer is passed for the name Invalid priority Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6

Ngày đăng: 10/08/2016, 09:56

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN