NXLwWorkSchedule

Schedules a light-weight work item.

Library:LibC
Classification:NKS
Service:Threads

Syntax

  #include <nks/thread.h> 
   
  int NXLwWorkSchedule (
     void         *reserved, 
     NXLwWork_t   *work, 
     NXBool_t      bind);
  

Parameters

reserved

(IN) Unused. Set to NULL.

work

(IN) Points to the light-weight work item to be scheduled.

bind

(IN) Specifies whether to bind to the current CPU:

  • TRUE Bind the work item to the CPU on which the function is called. This is purely a hint, and the system can ignore the hint.
  • FALSE No binding is requested.

Return Values

If successful, returns 0; otherwise, returns a nonzero error code:

Decimal

Hex

Constant

Description

9

0x09

NX_EINVAL

Invalid work context or lwWorkFunc is NULL.

62

0x3E

NX_EBUSY

Attempted to schedule work that has already been scheduled.

Remarks

NXLwWorkSchedule allows the caller to request CPU binding for the work being scheduled. However, this sends the system a preference, and the system is free to ignore it. For a binding request to be meaningful, you should be in a nonpreemptible context or be bound to the CPU on which the function is called.

This function's client is responsible for allocating and initializing the light-weight context object. NXLwWork_t defines a type struct lwWork and the caller must initialize the following fields:

  void  (*lwWorkFunc) (struct lwWork *, void *lwAppRef);
  void   *lwAppRef;
  

When called, the work function is passed a pointer to the work object (structure).The lwAppRef parameter is not interpreted.

An NKS light-weight work item is similar to a NetWare work-to-do item. Once a light-weight work is scheduled, its pointer can be used as the work handle if the work needs to be canceled (see NXLwWorkCancel for details). Once a light-weight work begins execution it cannot be canceled (see NXWorkSchedule for the standard NKS scheduling function).

The structure used in scheduling a light-weight work can be reused after the work begins execution or after the work has been canceled. You can schedule light-weight work from within an executing (light-weight) work context using the context structure that was used to specify initial work. (Note that this feature does not work from within NXWorkSchedule.)

NKS work elements support the notion of execution priority. Light-weight work elements are treated as high priority (NX_PRIO_HIGH).

See Also