• No results found

See Also

In document RTXC Kernel ServicesV2 Decrypted (Page 67-76)

task The number of the task being queried.

KS_GetTaskProp

KS_GetTaskProp

Get the properties of a task.

Synopsis

void KS_GetTaskProp (TASK task, TASKPROP *ptaskprop)

Inputs

Description

The KS_GetTaskProp kernel service obtains all of the property values of the specified task in a single call. The task argument may specify a static or a dynamic task. The service stores the property values in the TASKPROP structure pointed to by ptaskprop.

The TASKPROP structure has the following organization:

typedef struct {

void (*taskentry)(void); /* initial entry point addr. */

char *stackbase; /* initial stack base */

ksize_t stacksize; /* initial stack size */

PRIORITY priority; /* initial priority */

} TASKPROP;

Output

This service returns the properties of the task in the property structure pointed to by ptaskprop.

Errors

This service may generate one of the following fatal error codes:

` FE_ILLEGAL_TASK if the specified task ID is not valid.

` FE_UNINITIALIZED_TASK if the specified task has not yet been initialized.

Example

In Example 2-18 on page 55, the Current Task needs to terminate a dynamic task named DynMuxTask2, which is known to be running.

The Current Task must first call KS_TerminateTask to stop execution of the task, then release the terminated task’s stack space to the BLK256 memory partition from where it was initially allocated.

task The number of the task being queried.

ptaskprop A pointer to a task property structure.

KS_GetTaskProp

Example 2-18. Terminate Task and Release Its Stack

#include "rtxcapi.h" /* RTXC Kernel Service prototypes */

#include "kpart.h" /* defines BLK256 */

TASK dyntask;

static TASKPROP tprop;

/* first, get the task number of DynMuxTask2" */

if (KS_LookupTask ("DynMuxTask2", &dyntask) != RC_GOOD) {

... Task "DynMuxTask2" does not exist.

} else {

/* task was found, now get its properties */

KS_GetTaskProp (dyntask, &tprop);

/* terminate task */

KS_TerminateTask (dyntask);

/* Now free the block used for its stack */

KS_FreeBlk (BLK256, tprop.stackbase);

}

See Also

KS_DefTaskProp, page 34

KS_GetTaskSema

KS_GetTaskSema

Get the handle of the semaphore associated with the termination or abortion of a task.

Synopsis

SEMA KS_GetTaskSema (TASK task)

Input

Description

The KS_GetTaskSema kernel service obtains the handle of the semaphore associated with the termination or abortion of the static or dynamic task specified in task.

You must have previously associated the semaphore and the task event through a call to the KS_DefTaskSema service.

Note: To use this service, you must enable the Semaphores attribute of the Task class during system generation.

Output

If the task and semaphore association exists, this service returns the handle of the semaphore as a SEMA type value.

If there is no such association for the task, this service returns a SEMA value of zero (0).

Errors

This service may generate one of the following fatal error codes:

` FE_ILLEGAL_TASK if the specified task ID is not valid.

` FE_UNINITIALIZED_TASK if the specified task has not yet been initialized.

Example

In Example 2-19 on page 57, the Current Task needs to know the handle of the semaphore associated with the termination or abortion of the dynamic task specified in dyntask. If the return from KS_GetTaskSema indicates there is no semaphore defined, the Current Task defines the TASKTERM semaphore, adds it to semalist, and waits for the indicated events.

task The number of the task being queried.

KS_GetTaskSema

Example 2-19. Read Task Termination Semaphore

#include "rtxcapi.h" /* RTXC Kernel Service prototypes */

#include "ksema.h" /* defines TASKTERM, OEVENT */

SEMA semalist[] = {

OEVENT, /* other event */

(SEMA)0, /* tasksema, to be filled in below */

(SEMA)0 /* null terminator */

}

TASK dyntask;

SEMA tasksema, cause;

if ((tasksema = KS_GetTaskSema (dyntask)) == (SEMA)0) {

/* Semaphore undefined for dyntask */

KS_DefTaskSema (dyntask, TASKTERM); /* define one now */

tasksema = TASKTERM;

}

/* there is now a semaphore defined for dyntask */

/* store it in semalist */

semalist[1] = tasksema;

/* and wait for either event to occur */

cause = KS_TestSemaMW (semalist);

... continue processing according to cause of resumption

See Also

KS_DefTaskSema, page 36

KS_GetTaskState

KS_GetTaskState

Get the state of a task.

Synopsis

KSRC KS_GetTaskState (TASK task)

Input

Description

The KS_GetTaskState kernel service obtains the state of the static or dynamic task specified in task.

Output

This service returns a KSRC value as follows:

` RC_TASK_ACTIVE if the task has been previously made runnable by a KS_ExecuteTask request and is currently runnable or blocked on a condition other that ABORT_BLOCK or INACTIVE.

` RC_TASK_INACTIVE if the task is currently in an INACTIVE state.

` RC_TASK_ABORTED if the task is currently in an ABORT_BLOCK state.

Errors

This service may generate one of the following fatal error codes:

` FE_ILLEGAL_TASK if the specified task ID is not valid.

` FE_UNINITIALIZED_TASK if the specified task has not yet been initialized.

Example

In Example 2-20 on page 59, the Current Task needs to know the state of a task if the task fails to begin execution properly following a call to KS_ExecuteTask.

task The number of the task being queried.

KS_GetTaskState

Example 2-20. Read Task State

#include "rtxcapi.h" /* RTXC Kernel Service prototypes */

#include "ktask.h" /* defines TASKX */

if (KS_ExecuteTask (TASKX) != RC_GOOD ) {

/* Task was not started, why? */

if (KS_GetTaskState (TASKX) == RC_TASK_ACTIVE) {

...TASKX was active. deal with it }

else {

... TASKX was aborted. deal with it }

}

/* task TASKX was successfully started */

... continue

KS_GetTickSlice

KS_GetTickSlice

Get the tick-slice quantum of a task.

Synopsis

TSLICE KS_GetTickSlice (TASK task)

Input

Description

The KS_GetTickSlice kernel service obtains the value of the tick-slice quantum for the specified task. If there has been no tick-tick-slice quantum defined for task, the service returns a value of zero (0).

Note: To use this service, you must enable the Tick Slice attribute of the Task class during system generation.

Output

This service returns the specified task’s tick-slice quantum in units of system clock ticks as a TSLICE type value.

Errors

This service may generate one of the following fatal error codes:

` FE_ILLEGAL_TASK if the specified task ID is not valid.

` FE_UNINITIALIZED_TASK if the specified task has not yet been initialized.

Example

Example 2-21 gets the tick-slice quantum for the SCANR task. If the quantum has not been defined, it defines the task’s tick quantum as 100 msec.

Example 2-21. Read Task Tick-Slice Quantum

#include "rtxcapi.h" /* RTXC Kernel Service prototypes */

#include "ktask.h" /* defines SCANR */

#include "kproject.h" /* defines CLKTICK */

if (KS_GetTickSlice (SCANR) == (TICKS)0)

KS_DefTickSlice (SCANR, (TICKS)100/CLKTICK);

task The number of the task being queried.

KS_GetTickSlice

See Also

KS_DefTickSlice, page 38

In document RTXC Kernel ServicesV2 Decrypted (Page 67-76)

Related documents