载入中。。。

载入中。。。

公告

载入中。。。

文章

评论

留言

连接

   流媒体世界

信息

登陆

搜索

2006-10-16 16:01:00
uC/OS Usage Summary

This summary has been stayed some time in my Draft box, I am unwilling to interrupt the current logic on the mmu, but it takes time anyway, for this sake, so, just put a little words to track done my minds on this.

uC/OS is a RTO which is widely used in embedded world. As far as I know, mostly in ARM micro processors. Initially, I just don't believe a tiny chip can work on a OS, but this convenice me soon. uC/OS is a quite minimum OS with Interrupt, timer, task, message queue, mail box, none-mmu features. Any unnecessary features are kept out of its scope. the core of the above kernel codes only takes less than 15k memory. Thus, if the application doesn't take much more than 15k mem, then it is likely to use a 32k-cache chip for the app services.

Before running up your app, chip initialization should be done properly, this might include timer, ISR registery, peripheral dev registers. Once done, after bootup, the uC/OS will first execute the initialization instructions, then jump to the uC/OS core.

uC/OS is compiled-in together with the app code, they are totally mixed up. the main() has
to be like the following:

int main(void)
{
    ... ...

    OSInit();

    ... ...
    // MUST creat up N(>=1) tasks and do anything you like in there.
    ... ...

    OSStart();
}

The followings are the most likely required for an app.

Task Management:
OSTaskCreate() - aware of the declaration of the stack incremental direction.
OSTaskChangePrio()
OSTaskCreateExt() - extended version, more task configuration you can control/monitor.
OSTaskDel() - delete task by priority.
OSTaskDelReq() - delete the task itself, the deletion request is triggered by another task. The
    deleted task is waiting for the request, while the triggered task is waiting
    for the action result.
OSTaskResume() - resume a previously suspended task.
OSTaskStkChk() - check the amount of free memory left on the specified task's stack.
OSTaskSuspend() - suspend a task.
OSTaskQuery() - obtain a copy of the desired task's TCB.

Memory Management:
OSMemCreate() - creates a fixed-sized memory partition that will be managed by uC/OS.
OSMemGet() - gets a memory block from a partition.
OSMemPut() - returns a memory block to a partition.
OSMemQuery() - is used to determine the number of free memory blocks and used memory blocks from a memory partition.

This is a bit like the SLAB allocator, as it is also statistically allocated at the beginning.

Message Queue:
OSQCreate() - creates a message queue. message queue works as a message dispatcher, it provides two ways of inter-process communication: FIFO and LIFO.
OSQPost() - posts a message to the queue with FIFO.
OSQPostFront() - posts a message to the queue with LIFO.
OSQPostOpt() - it can replace the above two "post" methods, also, it adds the capability to 
    broadcast a message to all the tasks waiting on the message queue. Instead, the 
    OSQPost() and OSQPostFront() are only POSTing a message to a single waiting task.
OSQPend() - waits for a message to be posted to a queue, with a timeout pending.
OSQAccept() - checks the queue to see if a message is available. Unlike OSQPend(), it does not
    suspend the calling task if a message is not available. Normally, it is used in the ISR.
OSQDel() - deletes a message queue and readies all tasks pending on the queue.
OSQFlush() - flushs the contents of the message queue.
OSQQuery() - obtains information about a message queue through a OS_Q_DATA pointer.

For Mail box facilities, I personally think it is better to use Message queue instead, as the Mail
box only provides single message queuing, while message queue provides certain number of message queuing.

Time Management:
OSTimeDly() - delays a task N ticks.
OSTimeDlyHMSM() - delays a task for specified time.
OSTimeDlyResume() - resume a delayed task.
OSTimeGet() - gets current system time.
OSTimeSet() - sets system clock.

Interrupt diable/enable
OS_ENTER_CRITICAL() - disable cpu interrupts
OS_EXIT_CRITICAL() - enable cpu interrupts

they must be used in pair.



  • 标签:OS 
  • 发表评论:
    载入中。。。
    Powered by Oblog.