MultiTasking

LoseThos is a preemptive multitasking operating system.  However, you can 
turn-off preemption on a task by task basis and the task will not yield ctrl 
unless it volunteers with Yield(), Sleep() or a call to I/O which yields ctrl.  
Use the Preempt() cmd to turn on or off preemption.  This is useful when you 
have multiple tasks modifying data structures simultaneously.  Interrupts still 
occur when preemption is off.   

Preemption is turned-off by default when a task is Spawn()ed.

The time-slice rate is set by JIFFY_FREQ.

LoseThos does not remove tasks from "the queue" when they are waiting.  They 
swap-in, check for whatever condition they are waiting for and swap-out.  This 
keeps it simple, but would cause problems if too many tasks existed.  LoseThos 
is intended for non-server home computers with a maximum of around ten, or so, 
tasks.  See Scheduler.

LoseThos has no task priority scheme.

                                   Interrupts

You can turn-on and off interrupts, in your user programs.  This is part of the 
mission statement, giving complete freedom to programmers  Use Cli() or Sti().  
LoseThos currently doesn't use interrupt besides the timer and keyboard 
interrupt.  Since the interrupt flag is part of your task context and since you 
are voluntarily swapped-out if you call GetChar() or whatever, you won't even 
notice if you turn-off interrupts at the cmd prompt because you are being 
swapped-out and interrupts are being turned-on by the next task.  

I saw no reason to make the hard drive or CD-ROM drive code interrupt driven -- 
it just creates potential compatibility issues.  On a home system, you do one 
thing at a time, mostly.  LoseThos can do multiple things at once, but not as 
efficiently as a server operating system.  It would bogg down with a hundred 
tasks asking for service.  It sure is simpler, though... smaller... simpler to 
maintain... and understandable by a layman!  The disk code does not break-up 
requests, if you are curious why one task must wait until another finishes an 
operation.

See ::/LT/Demo/Lectures/Spinning.CPZ.
Historical capture: 2012-03-03. Home | Power on LoseThos | Sources and changes