Subject: how do I disable preemptive scheduling for the currently executing kproc?
To: None <>
From: Tad Hunt <>
List: tech-kern
Date: 07/17/2003 15:41:42
I'm porting a device driver which depends on VxWorks task primitives.
In particular, I'm working on some code which runs in a kernel
thread and depends on the taskLock() VxWorks API.

The semantics for taskLock()/taskUnlock() appear to be as follows:

1) taskLock() stops the calling process from being preempted by
   other processes.  The process can nest calls to this (see
   taskUnlock() below)

2) Other interrupts, including callouts (in vxworks world, these are
   called watchdogs) are allowed.

3) taskUnlock() re-enables preemption for the calling task.
   It must be called as many times as taskLock() before preemption
   is re-enabled. (That is, taskLock() increments a count and
   taskUnlock() decrements it.  When the count is 0, preemption
   is enabled)

4) If the process blocks after calling taskLock() (i.e., via tsleep),
   other processes get preemptively scheduled until it wakes up.

I am considering simply using a reference counting wrapper around
splsoftclock() as the solution, but I would rather not because then
all softclock processing will be blocked.  This means that callouts
won't be serviced during this time. 

Does anyone have a better solution?  I'd rather not go changing MI
parts of the kernel, but changing MD parts is fine.