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

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6Creating a Task, OSTaskCreate INT8U OSTaskCreate void *taskvoid *pd, void *pdata, OS_STK *ptos, INT8U prio • task: A pointer to the ta

Trang 1

Introduction to uCOS-II V2.6

Trang 2

Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6

About SwiftACT

• A Technology services startup company

o Under establishment

• Areas of specialties:

o Mobile telecommunication services development

o Embedded systems development

Trang 3

Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6

About Me

• Graduated 2004

o ECE, ASU: 5 yrs distinction

• 5+ years in embedded systems development

Trang 4

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

Trang 5

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

Trang 6

Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6

• Mutual Exclusion Semaphores

• Event Flag Management

• Message Mailbox Management

• Message Queue Management

• Memory Management

Trang 7

Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6

• Mutual Exclusion Semaphores

• Event Flag Management

• Message Mailbox Management

• Message Queue Management

• Memory Management

Trang 8

Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6

Task Management APIs

• Available task operations are:

o Task creation

o Stack checking

o Task deletion

o Requesting a task deletion

o Changing a task’s priority

o Task suspension

o Task resumption

o Getting task’s info

o Task name manipulation

Trang 9

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 No error

o Priority exist

o Invalid priority

Trang 10

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

Trang 11

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);

Trang 12

Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6

Task Stacks cont’d

• Dynamic allocation may suffer from fragmentation

• Your code should support stacks that grow in either direction

A (1KB)

C (1KB)

B (1KB)

#else OSTaskCreate(task, pdata, &TaskStack[stack_size-1], prior);

#endif

Trang 13

Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6

Stack Checking

• Assume stack is cleared at the beginning

Trang 14

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 No error

o Invalid priority

o Task does not exist.

o Task options does not support stack checking.

Trang 15

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 No error

o Invalid priority.

o Task does not exist.

o Deleting idle task

o Deleting a task from ISR

Trang 16

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){

} else{

/* Application code*/

}

}

Trang 17

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 No error

o Invalid priority

o Task does not exist.

o Deleting idle task

o Deleting a task from ISR

Trang 18

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 No error

o Invalid priority

o Task to change priority does not exist.

o New priority already exists.

o Changing IDLE priority

Trang 19

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 No error

o Invalid priority

o Task is not suspended.

o Task does not exist.

Trang 20

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 No error

o Invalid priority

o Suspending idle task

o Task does not exist

Trang 21

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

Trang 22

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 No error

o Task does not exist.

o A null pointer is passed for the name.

o Invalid priority

• Return value: Length of the string

Trang 23

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 No error

o Task does not exist.

o Name too long

o A null pointer is passed for the name.

o Invalid priority

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