These functions provide limited control over the scheduling of a
lightweight process (LWP). They allow a running LWP to give a hint to the kernel that preemptions of that LWP should be avoided. The most likely use for these functions is to block preemption while holding a spinlock. Improper use of this
facility, including attempts to block preemption for sustained periods of time, may result in reduced performance.
The schedctl_init() function initializes preemption control for the calling LWP and returns a pointer used to refer to the data. If schedctl_init() is called more than once by the same LWP, the
most recently returned pointer is the only valid one.
The schedctl_lookup() function returns the currently allocated preemption control data associated with the calling LWP that was previously returned by schedctl_init(). This can be useful in programs where it is difficult to maintain
local state for each LWP.
The schedctl_exit() function removes the preemption control data associated with the calling LWP.
The schedctl_start() macro gives a hint to the kernel scheduler that preemption should be avoided on the current LWP. The pointer passed to the macro must be the same as the pointer returned by the call to schedctl_init() by
the current LWP. The behavior of the program when other values are passed is undefined.
The schedctl_stop() macro removes the hint that was set by schedctl_start(). As with schedctl_start(), the pointer passed to the macro must be the same as the pointer returned by the call to schedctl_init() by the current LWP.
The schedctl_start() and schedctl_stop() macros are intended to be used to bracket short critical sections, such as the time spent holding a spinlock. Other uses, including the failure to call schedctl_stop() soon after calling schedctl_start(), might result in poor performance.
|