Tải bản đầy đủ (.ppt) (18 trang)

Introduction to uCOS II v2 6 m8

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (163.29 KB, 18 trang )

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: 5 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


Message Mailboxes


A message mailbox is
a μC/OS-II object that
allows a task or an
ISR to send pointersized variable to
another task.

OSMboxCreate()

OSMboxPost()
Task

OSMboxPend()
OSMboxAccept()
OSMboxQuery()
Task


ISR
OSMboxPost()
OSMboxAccept()

Amr Ali Abdel-Naby@2010

Introduction to uCOS-II V2.6

Message


Creating a Mailbox, OSMboxCreate
OS_EVENT *OSMboxCreate (void *msg)


msg: A pointer to a message to deposit in the mailbox
o
o



If null, mailbox is empty & used to signal occurrence of events
If ! null, mailbox is used to access shared resources

Return value:
o
o

Non-null for successful creation

Null for failure

Amr Ali Abdel-Naby@2010

Introduction to uCOS-II V2.6


Deleting a Mailbox, OSMboxDel
OS_EVENT *OSMboxDel (OS_EVENT *pevent, INT8U opt, INT8U
*err)



pevent: A pointer to the mailbox to be deleted
opt: Delete options
o
o



Delete always
Delete if no pending tasks

err:
o
o
o
o
o
o


No error
Called from ISR
Invalid option
There are tasks pending.
pevent is null.
pevent is not a mailbox.

Amr Ali Abdel-Naby@2010

Introduction to uCOS-II V2.6


Deleting a Mailbox, OSMboxDel
cont’d
OS_EVENT *OSMboxDel (OS_EVENT *pevent, INT8U opt, INT8U
*err)


Return value: Null if successful

Amr Ali Abdel-Naby@2010

Introduction to uCOS-II V2.6


Waiting for a Message at a Mailbox,
OSMboxPend
void *OSMboxPend (OS_EVENT *pevent, INT16U timeout, INT8U
*err)




pevent: A pointer to the mailbox to pend to
timeout:
o
o



err:
o
o
o
o
o

0  wait for ever
!0  wait with specific timeout
No error
Timeout
pevent is not a mailbox.
pevent is null.
Called from ISR

Amr Ali Abdel-Naby@2010

Introduction to uCOS-II V2.6



Sending a Message to a Mailbox,
OSMboxPost
INT8U OSMboxPost (OS_EVENT *pevent, void *msg)




pevent: A pointer to the mailbox to post to
msg: A pointer to the message to send
Return value:
o
o
o
o
o

No error
Mailbox is full.
pevent is not a mailbox.
pevent is null.
Posting a null pointer

Amr Ali Abdel-Naby@2010

Introduction to uCOS-II V2.6


Sending a Message to a Mailbox,
OSMboxPostOpt
INT8U OSMboxPostOpt (OS_EVENT *pevent, void *msg, INT8U

opt)



OSMboxPostOpt = OSMboxPost + options
opt:
o
o

Post to a single waiting task
Post to all tasks waiting

Amr Ali Abdel-Naby@2010

Introduction to uCOS-II V2.6


Getting a Message without Waiting,
OSMboxAccept
void *OSMboxAccept (OS_EVENT *pevent)



pevent: A pointer to the mailbox to pend to
Return value:
o
o

!Null  Message received
Null  Case of error or mailbox is empty


Amr Ali Abdel-Naby@2010

Introduction to uCOS-II V2.6


Obtaining the Status of a Mailbox,
OSMboxQuery
INT8U OSMboxQuery (OS_EVENT *pevent, OS_MBOX_DATA
*pdata)




pevent: A pointer to the desired mailbox
pdata: A pointer to the returned mailbox information
Return value:
o
o
o

No error
pevent is not a mailbox.
pevent is null.

Amr Ali Abdel-Naby@2010

Introduction to uCOS-II V2.6



Using a Mailbox as a Binary
Semaphore

OS_EVENT *MboxSem;
void Task (void *pdata){
INT8U err;
for (;;) {
OSMboxPend(MboxSem, 0, &err); /* Obtain access to resource */
/* Task has semaphore, access resources */
OSMboxPost(MboxSem, (void*)1); /* Release access to resource */
}
}

Amr Ali Abdel-Naby@2010

Introduction to uCOS-II V2.6


Using a Mailbox Instead to Signal
Occurrence of Events
OS_EVENT *MboxTimeDly;
void Task1(void *pdata){
INT8U err;
for (;;) {
OSMboxPend(MboxTimeDly, timeout, &err); /* Wait for event */
/* Code after time delay */
}
}
void Task2(void *pdata){
INT8U err;

for (;;) {
OSMboxPost(MboxTimeDly, (void *)1); /* Signal event */
...
}
}

Amr Ali Abdel-Naby@2010

Introduction to uCOS-II V2.6



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×