BRISCITS  0.1
RISC "Real-Time" Scheduler
The BISC Scheduler

The BRISC scheduler stores an static array of brisc_thread_t context structures.

The size of the storage if determined at compile time by the proprocessor constant BRISC_THREAD_MAX, which consequently determines the maximum number of threads which may exist at a given time.

BRISC divides time into fixed quanta of, typically, 1 millisecond.

The scheduler in invoked at each systick brisc_isr_systick() timer interrupt and at each brisc_isr_yield() interrupt.

The scheduler determines if the current thread should continue to run for another time.

See b_thread_set_prio() and b_thread_priority().

The priority of a thread is detemined by how many time quanta it is assigned at any given time. For instance, a thread with a priority of 2 will have a maximum of 2 time quanta in which to execute un-interrupted.

When a gived thread has exhausted it's time quanta, the scheduler will select the next thread in a round-robin manner.

See b_thread_yield().

If a thread chooses to yield it's time quanta, then the remainder of it's current time quanta is alotted to the next selected thread on top of the next thread's quanta budget.

See b_thread_lock() and b_thread_unlock().

There are times when a particular thread absolutely must not be swapped out durring a particular operation in order to reduce jitter or whatever the case may be.

Locking the scheduler staves other threads from recieving their time quanta while the current thread holds the scheduler lock.

Locking the scheduler obviously must be used with caution, and only if you completely understand the implications.