tk_ref_tsk
Reference Task Status
See Also
ER ercd = tk_ref_tsk ( ID tskid, T_RTSK *pk_rtsk ) ;
ID tskid Task ID
T_RTSK* pk_rtsk Address of packet for returning task status
ER ercd Error code
pk_rtsk detail:
VP exinf Extended information
PRI tskpri Current task priority
PRI tskbpri Base priority
UINT tskstat Task state
UW tskwait Wait factor
ID wid Waiting object ID
INT wupcnt Queued wakeup requests
INT suscnt Nested suspend requests
(Other implementation-dependent parameters may be added beyond this point.)
E_OK Normal completion
E_ID Invalid ID number (tskid is invalid or cannot be used)
E_NOEXS Object does not exist (the task specified in tskid does not exist)
E_PAR Parameter error (the address of the return parameter packet cannot be used)
Gets the state of the task specified in tskid.
tskstat takes the following values.
tskstat:
TTS_RUN 0x0001 RUN
TTS_RDY 0x0002 READY
TTS_WAI 0x0004 WAIT
TTS_SUS 0x0008 SUSPEND
TTS_WAS 0x000c WAIT-SUSPEND
TTS_DMT 0x0010 DORMANT
TTS_NODISWAI 0x0080 Wait state disabled
Task states such as TTS_RUN and TTS_WAI are expressed by corresponding bits, which is useful when making a complex state decision (e.g., deciding that the state is one of either RUN or READY state).
Note that, of the above states, TTS_WAS is a combination of TTS_SUS and TTS_WAI, but TTS_SUS is never combined with other states (TTS_RUN, TTS_RDY, and TS_DMT). In the case of TTS_WAI (including TTS_WAS), if wait states are disabled by tk_dis_wai, TTS_NODISWAI is set. TTS_NODISWAI is never combined with states other than TTS_WAI.
When tk_ref_tsk is executed for an interrupted task from an interrupt handler, RUN (TTS_RUN) is returned as tskstat.
When tskstat is TTS_WAI (including TTS_WAS), the values of tskwait and wid are as shown in Table 4.2.

Table 4.2: Values of tskwait and wid
- When
tskstatis not TTS WAI (including TTS WAS), bothtskwaitandwidare 0. - For a task in DORMANT state,
wupcnt= 0 andsuscnt= 0. - The invoking task can be specified by setting
tskid= TSK_SELF = 0. Note, however, that when a system call is issued from a task-independent portion andtskid= TSK_SELF = 0 is specified, error codeE_IDis returned. - When the task specified with
tk_ref_tskdoes not exist, error codeE_NOEXSis returned.
Even when tskid = TSK_SELF is specified in this system call, the ID of the invoking task is not known. Use tk_get_tid to find out the ID of the invoking task.
Maximum consecutive execution time (slicetime), wait-disabled waiting factor (waitmask), permitted task exception (texmask), and occurred task event (tskevent) are deleted from T_RTSK. Non-disable wait state (TTS_NODISWAI) is deleted from the values set to tskstat, and the value concerning task event (TTW_EVn) is deleted from the values set to tskwait. This is because, in µT-Kernel, there are no functions concerning timesharing execution, wait-disabled state, task exception, and task event.
tskwait, the member of T_RTSK, is of UW type instead of UINT type. In µT-Kernel, 16-bit width is sufficient for this member, but 32-bit width is required for T-Kernel. Therefore, this member is modified to UW type based on the policy that those that require 32-bit width are set to the W/UW types whose bit widths are explicitly defined.

Comments
Click here to Post a Comment