PxServiceTaskInit()
Instantiate the calling task as PXROS service task.
- APPLIES TO
-
1.0.0
- SYNOPSIS
-
PxError_t PxServiceTaskInit (void);
- RETURN VALUES
-
-
PXROS error code
-
- ERROR CODES
-
PXERR_ACCESS_RIGHT
The calling task has not the right to act as a service task
PXERR_TASK_DIESRV_INITIALIZED
The dieserver is (seems to be) already initialized
- DESCRIPTION
-
PxServiceTaskInit instantiates the calling task as the PXROS service task. The PXROS service task is responsible to call PxDieService on request. There are two special events which announce the PXROS service task to call this service. The event PXSERVICE_TASK_DIED is signaled from the systemcall PxDie after the calling task has been suspended and is no longer scheduled and ready for deletion. In receiving this event the PXROS service task has to call PxDieService to remove the terminated task from the system.
An example for a PXROS service task could be:
PxError_t ServiceTaskCode(void) { PxMbx_t relmbx; PxEvents_t ev; PxError_t err; relmbx = PxMbxRequest(PXOpoolTaskdefault); // or relmbx = PxTaskGetMbx(PxGetId()); if (PxMbxIdError(relmbx) != PXERR_NOERROR) return PxMbxIdError(relmbx); err = PxServiceTaskInit(); if (err != PXERR_NOERROR) return err; while(1) { ev = PxAwaitEvents(PXSERVICE_TASK_DIED); if (ev & PXSERVICE_TASK_DIED) { err = PxDieService(); if (err != PXERR_NOERROR) { // do error handling } } } }
- IMPLEMENTATION GUIDELINES
-
- Before call
-
-
The calling task must have the right to act as service task
(PXACCESS_SYSTEM_CONTROL)
. (V)
-
- After call
-
-
The function returns
PXERR_NOERROR
if the task could be installed as service task. Any other return value describes an error, which has to be interpreted (C).
-
- Best Practice
-
-
No restrictions
-
- SEE ALSO
- USAGE
-
#include "pxdef.h" PxError_t err = PxServiceTaskInit(); if (err != PXERR_NOERROR) { // Report error }