Maxim Integrated High-Speed Microcontroller Users Guide: Network Microcontroller Supplement User Manual

Page 206

Advertising
background image

High-Speed Microcontroller User’s

Guide: Network Microcontroller

Supplement

206

task_getpriority

Description:

int task_getpriority(

int id);

/* id of the task for which we want to get priority */

The

task_getpriority function returns the priority of a task. It returns the priority of the task with the given id. The current task

always has ID = 0. This function returns a success/failure code in the accumulator (ACC) SFR and the task priority in the B

SFR.

task_setpriority

Description:

int task_setpriority(

int id,

/* id of the task for which we want to set priority */

int priority);

/* priority that we wish to assign to task with id */

The

task_setpriority function changes a task priority. ID 0 means current task. The priority is a value in the range

MIN_PRIORITY...MAX_PRIORITY, with an idle task running at MIN_PRIORITY and a regular task running at NORM_PRIORITY.

This function returns a success/failure code in the accumulator (ACC) SFR.

task_fork

Description:

int task_fork(

int priority,

/* priority that we wish to assign to the task */

int savesize);

/* buffer of savesize allocated */

The

task_fork function creates and executes a new task. It creates a new task and links it into a running task list with the given

priority. This function creates a duplicate of the current task and assigns it a new task id. The new task returns with a zero id,

and the parent gets the child id as a return value. This function also returns a success/failure code in the accumulator (ACC).

It calls

malloc to allocate a buffer of savesize, which is used to save and restore the task’s state. The priority value is a user-

assigned value in the range MIN_PRIORITY...MAX_PRIORITY.

INPUT

DESCRIPTION

OUTPUT

DESCRIPTION

ACC

R1:R0

priority

savesize

ACC

R0

Success (= 00h) or failure code

Child task ID or 0h if child

Example:

; Create a DHCP task

MOV R1, #high(SAVESIZE)

MOV R0, #low(SAVESIZE)

MOV A, #NORM_PRIORITY

ROMCALL task_fork

JNZ dhcp_init_exit

; this is a child task – run the FSM

AJMP dhcp_run

Dhcp_init_parent:

;record the DHCP task id

MOV DPTR, #DHCP_TASKID

MOVX A, @DPTR

INPUT

DESCRIPTION

OUTPUT

DESCRIPTION

ACC

B

id

priority

ACC

Success (= 00h) or failure code

Example:

CLR A

MOV B, #NORM_PRIORITY-1

ROMCALL task_setpriority

INPUT

DESCRIPTION

OUTPUT

DESCRIPTION

ACC

id

ACC

B

Success (= 00h) or failure code

task priority

Example:

MOV A, #…

ROMCALL task_getpriority

Maxim Integrated

Advertising