VxWorks Reference Manual : Libraries
kernelLib - VxWorks kernel library
kernelInit( ) - initialize the kernel
kernelVersion( ) - return the kernel revision string
kernelTimeSlice( ) - enable round-robin selection
The VxWorks kernel provides tasking control services to an application. The libraries kernelLib, taskLib, semLib, tickLib, and wdLib comprise the kernel functionality. This library is the interface to the VxWorks kernel initialization, revision information, and scheduling control.
The kernel must be initialized before any other kernel operation is performed. Normally kernel initialization is taken care of by the system configuration code in usrInit( ) in usrConfig.c.
Kernel initialization consists of the following:
- (1)
- Defining the starting address and size of the system memory partition. The malloc( ) routine uses this partition to satisfy memory allocation requests of other facilities in VxWorks.
- (2)
- Allocating the specified memory size for an interrupt stack. Interrupt service routines will use this stack unless the underlying architecture does not support a separate interrupt stack, in which case the service routine will use the stack of the interrupted task.
- (3)
- Specifying the interrupt lock-out level. VxWorks will not exceed the specified level during any operation. The lock-out level is normally defined to mask the highest priority possible. However, in situations where extremely low interrupt latency is required, the lock-out level may be set to ensure timely response to the interrupt in question. Interrupt service routines handling interrupts of priority greater than the interrupt lock-out level may not call any VxWorks routine.
Once the kernel initialization is complete, a root task is spawned with the specified entry point and stack size. The root entry point is normally usrRoot( ) of the usrConfig.c module. The remaining VxWorks initialization takes place in usrRoot( ).
Round-robin scheduling allows the processor to be shared fairly by all tasks of the same priority. Without round-robin scheduling, when multiple tasks of equal priority must share the processor, a single non-blocking task can usurp the processor until preempted by a task of higher priority, thus never giving the other equal-priority tasks a chance to run.
Round-robin scheduling is disabled by default. It can be enabled or disabled with the routine kernelTimeSlice( ), which takes a parameter for the "time slice" (or interval) that each task will be allowed to run before relinquishing the processor to another equal-priority task. If the parameter is zero, round-robin scheduling is turned off. If round-robin scheduling is enabled and preemption is enabled for the executing task, the routine tickAnnounce( ) will increment the task's time-slice count. When the specified time-slice interval is completed, the counter is cleared and the task is placed at the tail of the list of tasks at its priority. New tasks joining a given priority group are placed at the tail of the group with a run-time counter initialized to zero.
If a higher priority task preempts a task during its time-slice, the time-slice of the preempted task count is not changed for the duration of the preemption. If preemption is disabled during round-robin scheduling, the time-slice count of the executing task is not incremented.
kernelLib.h
kernelLib, taskLib, intLib, VxWorks Programmer's Guide: Basic OS
kernelInit( ) - initialize the kernel
void kernelInit ( FUNCPTR rootRtn, /* user start-up routine */ unsigned rootMemSize, /* memory for TCB and root stack */ char * pMemPoolStart, /* beginning of memory pool */ char * pMemPoolEnd, /* end of memory pool */ unsigned intStackSize, /* interrupt stack size */ int lockOutLevel /* interrupt lock-out level (1-7) */ )
This routine initializes and starts the kernel. It should be called only once. The parameter rootRtn specifies the entry point of the user's start-up code that subsequently initializes system facilities (i.e., the I/O system, network). Typically, rootRtn is set to usrRoot( ).
Interrupts are enabled for the first time after kernelInit( ) exits. VxWorks will not exceed the specified interrupt lock-out level during any of its brief uses of interrupt locking as a means of mutual exclusion.
The system memory partition is initialized by kernelInit( ) with the size set by pMemPoolStart and pMemPoolEnd. Architectures that support a separate interrupt stack allocate a portion of memory for this purpose, of intStackSize bytes starting at pMemPoolStart.
The interrupt stack is emulated by software, and it has to be located in a fixed physical address space (P1 or P2) if the on-chip MMU is enabled. If pMemPoolStart is in a logical address space (P0 or P3), the interrupt stack area is reserved on the same logical address space. The actual interrupt stack is relocated to a fixed physical space pointed by VBR.
N/A
kernelVersion( ) - return the kernel revision string
char *kernelVersion (void)
This routine returns a string which contains the current revision of the kernel. The string is of the form "WIND version x.y", where "x" corresponds to the kernel major revision, and "y" corresponds to the kernel minor revision.
A pointer to a string of format "WIND version x.y".
kernelTimeSlice( ) - enable round-robin selection
STATUS kernelTimeSlice ( int ticks /* time-slice in ticks or 0 to disable round-robin */ )
This routine enables round-robin selection among tasks of same priority and sets the system time-slice to ticks. Round-robin scheduling is disabled by default. A time-slice of zero ticks disables round-robin scheduling.
For more information about round-robin scheduling, see the manual entry for kernelLib.
OK, always.