tk_ref_tsk
Reference Task Status
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
UINT tskwait Wait factor
ID wid Waiting object ID
INT wupcnt Queued wakeup requests
INT suscnt Nested suspend requests
RELTIM slicetime Maximum continuous run time allowed (ms)
UINT waitmask Disabled wait factors
UINT texmask Allowed task exceptions
UINT tskevent Task events
(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 return parameter packet address cannot be used)
Gets the state of the task specified in tskid.
tskstat takes the following values.
tskstat: TTS RUN 0×0001 RUN
TTS RDY 0×0002 READY
TTS WAI 0×0004 WAIT
TTS SUS 0×0008 SUSPEND
TTS WAS 0×000c SUSPEND
TTS DMT 0×0010 DORMANT
TTS NODISWAI 0×0080 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, TTS 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.
tskwait
Value
Description
wid
TTW_SLP
0×00000001
Wait caused by tk_slp_tsk
0
TTW_DLY
0×00000002
Wait caused by tk_dly_tsk
0
TTW_SEM
0×00000004
Wait caused by tk_wai_sem
semid
TTW_FLG
0×00000008
Wait caused by tk_wai_flg
flgid
TTW_MBX
0×00000040
Wait caused by tk rcv mbx
mbxid
TTW_MTX
0×00000080
Wait caused by tk_loc_mtx
mtxid
TTW_SMBF
0×00000100
Wait caused by tk_snd_mbf
mbfid
TTW_RMBF
0×00000200
Wait caused by tk_rcv_mbf
mbfid
TTW_CAL
0×00000400
Wait caused by tk_rcv_mbf
porid
TTW_ACP
0×00000800
Wait for rendezvous acceptance
porid
TTW_RDV
0×00001000
Wait for rendezvous completion
0
(TTW_CAL|TTW_RDV)
0×00001400
Wait on rendezvous call or wait for rendezvous completion
0
TTW_MPF
0×00002000
Wait for tk_get_mpf
mpfi
TTW_MPL
0×00004000
Wait for tk_get_mpl
mplid
TTW_EV1
0×00010000
Wait for task event #1
0
TTW_EV2
0×00020000
Wait for task event #1
0
TTW_EV3
0×00040000
Wait for task event #3
0
TTW_EV4
0×00080000
Wait for task event #3
0
TTW_EV5
0×00100000
Wait for task event #5
0
TTW_EV6
0×00200000
Wait for task event #5
0
TTW_EV7
0×00400000
Wait for task event #7
0
TTW_EV8
0×00800000
Wait for task event #8
0
Table 4.2: Values of tskwait and wid
When tskstat is not TTS WAI (including TTS WAS), both tskwait and wid are 0.
waitmask is the same bit array as tskwait.
For a task in DORMANT state, wupcnt = 0, suscnt = 0, and tskevent = 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 and tskid = TSK_SELF = 0 is specified, error code E_ID is returned.
When the task specified with tk_ref_tsk does not exist, error code E_NOEXS is returned.
Even when tskid = TSK_SELF is specified with this system call, the ID of the invoking task is not known. Use tk_get_tid to .nd out the ID of the invoking task.

Comments