- •Preface
- •Introduction
- •1.01 INCLUDES.H
- •1.02 Compiler Independent Data Types
- •1.03 Global Variables
- •1.04 OS_ENTER_CRITICAL() and OS_EXIT_CRITICAL()
- •1.05 PC Based Services
- •1.05.01 PC Based Services, Character Based Display
- •1.05.02 PC Based Services, Elapsed Time Measurement
- •1.05.03 PC Based Services, Miscellaneous
- •1.07 Example #1
- •1.08 Example #2
- •1.09 Example #3
- •2.00 Foreground/Background Systems
- •2.01 Critical Section of Code
- •2.02 Resource
- •2.03 Shared Resource
- •2.04 Multitasking
- •2.05 Task
- •2.06 Context Switch (or Task Switch)
- •2.07 Kernel
- •2.08 Scheduler
- •2.09 Non-Preemptive Kernel
- •2.10 Preemptive Kernel
- •2.11 Reentrancy
- •2.12 Round Robin Scheduling
- •2.13 Task Priority
- •2.14 Static Priorities
- •2.15 Dynamic Priorities
- •2.16 Priority Inversions
- •2.17 Assigning Task Priorities
- •2.19 Mutual Exclusion
- •2.20 Deadlock (or Deadly Embrace)
- •2.21 Synchronization
- •2.22 Event Flags
- •2.23 Intertask Communication
- •2.24 Message Mailboxes
- •2.25 Message Queues
- •2.26 Interrupts
- •2.27 Interrupt Latency
- •2.28 Interrupt Response
- •2.29 Interrupt Recovery
- •2.30 Interrupt Latency, Response, and Recovery
- •2.31 ISR Processing Time
- •2.32 Non-Maskable Interrupts (NMIs)
- •2.33 Clock Tick
- •2.34 Memory Requirements
- •2.35 Advantages and Disadvantages of Real-Time Kernels
- •2.36 Real-Time Systems Summary
- •3.00 Critical Sections
- •3.01 Tasks
- •3.02 Task States
- •3.03 Task Control Blocks (OS_TCBs)
- •3.04 Ready List
- •3.05 Task Scheduling
- •3.06 Locking and Unlocking the Scheduler
- •3.07 Idle Task
- •3.08 Statistics Task
- •3.10 Clock Tick
- •3.14 OSEvent???() functions
- •4.00 Creating a Task, OSTaskCreate()
- •4.01 Creating a Task, OSTaskCreateExt()
- •4.02 Task Stacks
- •4.03 Stack Checking, OSTaskStkChk()
- •4.04 Deleting a Task, OSTaskDel()
- •4.05 Requesting to delete a task, OSTaskDelReq()
- •4.06 Changing a Task’s Priority, OSTaskChangePrio()
- •4.07 Suspending a Task, OSTaskSuspend()
- •4.08 Resuming a Task, OSTaskResume()
- •4.09 Getting Information about a Task, OSTaskQuery()
- •5.00 Delaying a task, OSTimeDly()
- •5.01 Delaying a task, OSTimeDlyHMSM()
- •5.02 Resuming a delayed task, OSTimeDlyResume()
- •5.03 System time, OSTimeGet() and OSTimeSet()
- •6.00 Event Control Blocks
- •6.01 Initializing an ECB, OSEventWaitListInit()
- •6.02 Making a task ready, OSEventTaskRdy()
- •6.03 Making a task wait for an event, OSEventTaskWait()
- •6.04 Making a task ready because of a timeout, OSEventTO()
- •6.05 Semaphores
- •6.06 Message Mailboxes
- •6.07 Message Queues
- •7.00 Memory Control Blocks
- •7.01 Creating a partition, OSMemCreate()
- •7.02 Obtaining a memory block, OSMemGet()
- •7.03 Returning a memory block, OSMemPut()
- •7.04 Obtaining status about memory partition, OSMemQuery()
- •7.05 Using memory partitions
- •7.06 Waiting for memory blocks from a partition
- •8.00 Development Tools
- •8.01 Directories and Files
- •8.02 INCLUDES.H
- •9.00 Development Tools
- •9.01 Directories and Files
- •9.02 INCLUDES.H
- •9.06 Memory requirements
- •9.07 Execution times
- •10.00 Directories and Files
- •10.01 INCLUDES.H
- •10.02.01 OS_CPU.H, Compiler specific data types
- •10.02.02 OS_CPU.H, OS_ENTER_CRITICAL() and OS_EXIT_CRITICAL()
- •10.02.03 OS_CPU.H, OS_STK_GROWTH
- •10.02.04 OS_CPU.H, OS_TASK_SW()
- •10.03.01 OS_CPU_A.ASM, OSStartHighRdy()
- •10.03.02 OS_CPU_A.ASM, OSCtxSw()
- •10.03.03 OS_CPU_A.ASM, OSIntCtxSw()
- •10.03.04 OS_CPU_A.ASM, OSTickISR()
- •10.04.01 OS_CPU_C.C, OSTaskStkInit()
- •10.04.02 OS_CPU_C.C, OSTaskCreateHook()
- •10.04.03 OS_CPU_C.C, OSTaskDelHook()
- •10.04.04 OS_CPU_C.C, OSTaskSwHook()
- •10.04.05 OS_CPU_C.C, OSTaskStatHook()
- •10.04.06 OS_CPU_C.C, OSTimeTickHook()
- •10.05 Summary
- •OSInit()
- •OSIntEnter()
- •OSIntExit()
- •OSMboxAccept()
- •OSMboxCreate()
- •OSMboxPend()
- •OSMboxPost()
- •OSMboxQuery()
- •OSMemCreate()
- •OSMemGet()
- •OSMemPut()
- •OSMemQuery()
- •OSQAccept()
- •OSQCreate()
- •OSQFlush()
- •OSQPend()
- •OSQPost()
- •OSQPostFront()
- •OSQQuery()
- •OSSchedLock()
- •OSSchedUnlock()
- •OSSemAccept()
- •OSSemCreate()
- •OSSemPend()
- •OSSemPost()
- •OSSemQuery()
- •OSStart()
- •OSStatInit()
- •OSTaskChangePrio()
- •OSTaskCreate()
- •OSTaskCreateExt()
- •OSTaskDel()
- •OSTaskDelReq()
- •OSTaskResume()
- •OSTaskStkChk()
- •OSTaskSuspend()
- •OSTaskQuery()
- •OSTimeDly()
- •OSTimeDlyHMSM()
- •OSTimeDlyResume()
- •OSTimeGet()
- •OSTimeSet()
- •OSTimeTick()
- •OSVersion()
}
}
OSTimeDlyHMSM()
void OSTimeDlyHMSM(INT8U hours, INT8U minutes, INT8U seconds, INT8U milli);
File |
Called from |
Code enabled by |
OS_TIME.C |
Task only |
N/A |
OSTimeDlyHMSM() allows a task to delay itself for a user specified amount of seconds and milliseconds. This is a more convenient and natural format than ticks. at least one of the parameters is non-zero.
time specified in hours, minutes, Rescheduling always occurs when
Arguments
hours is the number of hours that the task will be delayed. The valid range of values is from 0 to 255 hours.
minutes is the number of minutes that the task will be delayed. The valid range of values is from 0 to 59. seconds is the number of seconds that the task will be delayed. The valid range of values is from 0 to 59.
milli is the number of milliseconds that the task will be delayed. The valid range of values is from 0 to 999. Note that the resolution of this argument is in multiples o f the tick rate. For instance, if the tick rate is set to 10 mS then a delay of 5 mS would result in no delay. The delay is actually rounded to the nearest tick. Thus, a delay of 15 mS would actually result in a delay of 20 mS.
Returned Value
OSTimeDlyHMSM() returns one of the following error codes:
1)OS_NO_ERR, if you specified valid arguments and the call was successful.
2)OS_TIME_INVALID_MINUTES, if the minutes argument is greater than 59.
3)OS_TIME_INVALID_SECONDS, if the seconds argument is greater than 59.
4)OS_TIME_INVALID_MS, if the milliseconds argument is greater than 999.
5)OS_TIME_ZERO_DLY, if all four arguments are 0.
Notes/Warnings
Note that calling this function with a delay of 0 hours, 0 minutes, 0 seconds and 0 milliseconds results in no delay and thus the function returns immediately to the caller. Also, if the total delay time ends up being larger than 65535 clock ticks then, you will not be able to abort the delay and resume the task by calling OSTimeDlyResume().
Example
void TaskX(void *pdata)
{
for (;;) {
.
.
OSTimeDlyHMSM(0, 0, 1, 0); /* Delay task for 1 second */
.
.
}
}
OSTimeDlyResume()
INT8U OSTimeDlyResume(INT8U prio);
File |
Called from |
Code enabled by |
OS_TIME.C |
Task only |
N/A |
OSTimeDlyResume() allows your application to resume a task that has been delayed through a call to either
OSTimeDly() or OSTimeDlyHMSM().
Arguments
prio specifies the priority of the task to resume.
Returned Value
OSTimeDlyResume() returns one of the following error codes:
1)OS_NO_ERR, if the call was successful.
2)OS_PRIO_INVALID, if you specified a task priority greater than OS_LOWEST_PRIO.
3)OS_TIME_NOT_DLY, if the task is not waiting for time to expire.
4)OS_TASK_NOT_EXIST, if the task has not been created.
Notes/Warnings
Note that you MUST NOT call this function to resume a task that is waiting for an event with timeout. This situation would make the task look like a timeout occurred (unless you desire this effect).
You cannot resume a task that has calledOSTimeDlyHMSM() with a combined time that exceeds 65535 clock ticks. In other words, if the clock tick runs at 100 Hz then, you will not be able to resume a delayed task that called
OSTimeDlyHMSM(0, 10, 55, 350) or higher.
(10 Minutes * 60 + 55 Seconds + 0.35) * 100 ticks/second
Example
void TaskX(void *pdata)
{
INT8U err; |
|
|
pdata = pdata; |
|
|
for (;;) { |
|
|
. |
|
|
err = OSTimeDlyResume(10); |
/* Resume task with priority 10 |
*/ |
if (err == OS_NO_ERR) { |
/* Task was resumed |
*/ |
. |
||
. |
|
|
} |
|
|
. |
|
|
} |
|
|
} |
|
|
OSTimeGet()
INT32U OSTimeGet(void);
File |
Called from |
Code enabled by |
OS_TIME.C |
Task or ISR |
N/A |
OSTimeGet() allows a task obtain the current value of the system clock. The system clock is a 32-bit counter that counts the number of clock ticks since power was applied or since the system clock was last set.
Arguments
NONE
Returned Value
The current system clock value (in number of ticks).
Notes/Warnings
NONE
Example
void TaskX(void *pdata)
{
INT32U clk;
for (;;) {
.
.
clk = OSTimeGet(); /* Get current value of system clock */
.
.
}
}
OSTimeSet()
void OSTimeSet(INT32U ticks);
File |
Called from |
Code enabled by |
OS_TIME.C |
Task or ISR |
N/A |
OSTimeSet() allows a task to set the system clock. The system clock is a 32-bit counter which counts the number of clock ticks since power was applied or since the system clock was last set.
Arguments
ticks is the desired value for the system clock, in ticks.
Returned Value
NONE
Notes/Warnings
NONE
Example
void TaskX(void *pdata)
{
for (;;) {
.
.
OSTimeSet(0L); /* Reset the system clock */
.
.
}
}
OSTimeTick()
void OSTimeTick(void);
File |
Called from |
Code enabled by |
OS_TIME.C |
Task or ISR |
N/A |
OSTimeTick() is used to process a clock tick. expire (because they called OSTimeDly() or timeout.
µC/OS-II checks all tasks to see if they were either waiting for time to OSTimeDlyHMSM()) or, are waiting for events to occur until they
Arguments
NONE
Returned Value
NONE