Back to Convert 8086 to ARM.
uC/OS description in a nut shell.
uC/OS TASK STATES.
A task is a separately executing thread with defined code, data, and stack. Several tasks may share the same code, and possibly the same data, but never can they share same stack.
Tasks in uC/OS may be in 6 states. (see Figure 5)
A DORMANT task is in memory and has been linked but is not curently been assigned to a Task Control Block (TCB) and has not been assigned a priority.
A Task is READY after it has been created. It is assigned a TCP, a stack, a data area, and a priority. A Task is RUNNING when the CPU is actually running its code.
A Task may be INTERRUPTED when the CPU has responds to an interrupt.
In uC/OS the task may suspended (returned to READY state with a context switch) within the interrupted state if the interrupt changes the states of other, higher priority tasks to READY.
The Task may be DELAYED if it makes a Delay for N ticks by calling OSTaskDelay(). After N ticks of the clock the task is returned to the READY state and may run if it has the highest priority.
A Task may also be WAITING if it is pending (waiting) for an message, semaphore, or queue. Inherent in the design of uC/OS is a timeout for the WAITING state. When a timeout is enabled, the task will return to the ready state with a return value in an known error location to signal the task that it did not complete with the requested information returned.
Tasks in uC/OS are created - that is they are made known to the uC/OS kernel with the OSTaskCreate() call. They are deleted - put back into the DORMANT state with the OSTaskDel() call.
Each task has a priority which is unique, there are 64 priorities and a maximum of 63 tasks (The lowest priority task is preassigned to the NULL task). Since tasks may change priority with the OSTaskChangePrio() call, a full complement of 63 tasks would be inflexible.
SEMAPHORES A Semaphore is a signed integer that initialized to a positive integer or 0 before use. A positive value indicates the size of a resource while a negative value indicates how many tasks are waiting. Semaphores are created by OSSemCreate() which returns its EVENT pointer or "handle". A Task that is waiting to the semaphore calls OSSemPend(). If the count value is positive, it decrements it and returns. If the value is 0 or negative, it decrements the counter and places the caller in waiting list for the semaphore and also may place the calling task in the WAIT state with a timeout value. A semaphore is signaled by calling OSSemPost(). The semaphore count is incremented. If the semaphore count is negative then the waiting task with the highest priority is placed in the READY state and its timeout value is zeroed. There is no delete semaphore call.
MAILBOXES In uC/OS a message is passed through a Mailbox, which is really a pointer value. Mailboxes are created through OSMboxCreate() which returns and EVENT pointer. If a task want the message it calls OSMboxPend(). This call will return the message pointer and vhange it to a NULL. If the pointer is already NULL then the calling task is placed in a WAIT state with a timeout. To post a message a task calls OSMboxPost(). If the mailbox is already full it returns with an error. If there are tasks waiting on the mailbox it sends it to the highest priority task, making it READY, and resets the mailbox to NULL. There is no delete mailbox call.
QUEUES Queues are similar to mailboxes, but in addition they allow for a definable set of items to be posted and used in FIFO fashion. With OSQCreate(), a task allocates an EVENT and an array of pointers to the Queue storage area. A task that desires an item from the Queue calls OSQPend(). If there are any available items then the first one in the FIFO is popped off and returned. If the Queue is empty then the caller is placed in WAIT state or until a timeout occurs. To place an item on the Queue, OSQPost() is called. If the Queue is full then the call returns with an error. There is no delete Queue call.
Back to Convert 8086 to ARM.