Utility functions are used commonly from general programs such as applications, middleware, and device drivers on the T-Kernel.
Utility functions are provided as library functions or C language macros.
![]() | Difference from T-Kernel 1.0 |
---|---|
These functions were added in T-Kernel 2.0. |
API for setting object name is provided as C language macros. It can be called from a task-independent portion and while task dispatching and interrupts are disabled.
None
None
Interprets the ASCII string of four or less characters specified in name
as a single 32-bit data to store it in exinf
.
This API is defined as a C language macro and exinf
is not a pointer. Write a variable directly.
This API can be used to set a name (task name, etc.) for an individual object in T-Kernel as an ASCII string in the extended information exinf
. When displaying the state of an object in the debugger, the object name set by this API can be shown by displaying the value in exinf
as an ASCII string.
This API was added in T-Kernel 2.0.
Fast lock and multi-lock libraries are for performing exclusion control faster between multiple tasks in the device drivers or subsystems. In order to perform the exclusion control, while semaphore or mutex can be used, fast lock is implemented as the T-Kernel/SM library functions that processes the lock acquisition operation with specially higher speed when the task is not queued.
Among the fast lock and multi-lock libraries, the fast lock is a binary semaphore for mutual exclusion control faster than semaphores or mutexes. Fast multi-lock is one object built by combining 32 independent binary semaphores for mutual exclusion control each of which is distinguished by a lock number from 0 to 31.
For example, when exclusion control is performed at ten locations, one fast multi-lock can be created and then the binary semaphores with lock numbers from 0 to 9 can be used to perform exclusion control while ten fast locks can be used. While using ten fast locks bring faster result, the total required resources is lower when the fast multi-lock is used.
![]() | Additional Notes |
---|---|
Fast lock function is implemented by using counters that show the lock states and a semaphore. Fast multi-lock function is implemented by using a counter that shows the lock states and event flags. When the invoking task is not queued at the lock acquisition, it performs faster than the usual semaphores or event flags because only counter operation is performed. On the other hand, when the invoking task is queued at lock acquisition, it is not necessarily faster than the usual semaphores or event flags because it uses usual semaphores and event flags to manage transitions to waiting state or queues. Fast lock and multi-lock are effective when possibility of being queued is low due to mutual exclusion control. |
![]() | Difference from T-Kernel 1.0 |
---|---|
These libraries were added in T-Kernel 2.0. |
Creates a fast lock.
lock
is a structure to control a fast lock. name
is the name of the fast lock and can be NULL.
Fast lock is a binary semaphore used for mutual exclusion control and is implemented to be operated as fast as possible.
This API was added in T-Kernel 2.0.
None
None
This API was added in T-Kernel 2.0.
None
None
Locks a fast lock.
If the lock is already locked, the invoking task goes to the waiting state and is put in the task queue until it is unlocked. Tasks are queued in the priority order.
Error detection is omitted for faster operation.
This API was added in T-Kernel 2.0.
None
None
Unlocks a fast lock.
If there are tasks waiting for the fast lock, the first task in the task queue newly acquires the lock.
Error detection is omitted for faster operation.
This API was added in T-Kernel 2.0.
Creates a fast multi-lock.
lock
is a structure to control a fast multi-lock. name
is the name of the fast multi-lock and can be NULL.
Fast multi-lock is a list of 32 independent binary semaphores used for mutual exclusion control and is implemented to be operated as fast as possible. Each of the 32 binary semaphores is specified by a lock number from 0 to 31.
This API was added in T-Kernel 2.0.
Deletes a fast multi-lock.
This API was added in T-Kernel 2.0.
Locks a fast multi-lock.
no
is a lock number from 0 to 31.
If the lock is already locked with the same lock number, the invoking task goes to the waiting state and is put in the task queue until it is unlocked with the same lock number. Tasks are queued in the priority order.
This API was added in T-Kernel 2.0.
Locks a fast multi-lock with timeout.
This API is identical to MLock(), except that it can specify the timeout interval in tmout
. If the lock cannot be acquired before the timeout interval specified in tmout
has elapsed, E_TMOUT is returned.
This API was added in T-Kernel 2.0.
Locks a fast multi-lock with timeout in microseconds.
This API is identical to MLockTmo(), except that the timeout interval is specified with a 64-bit value in microseconds.
This API was added in T-Kernel 2.0.
Unlocks a fast multi-lock.
no
is a lock number from 0 to 31.
If there are tasks in the waiting state for the same lock number, the first task in the task queue newly acquires the lock.
This API was added in T-Kernel 2.0.