[comp.sys.amiga.tech] Time Slices

griffith@eecs.cs.pdx.edu (Michael Griffith) (10/02/90)

I noticed that the system programmer's guide just says that CIA-A's B timer
is used for various OS tasks and I was wondering:

   a. Is it used for the task-switching process? If not, what is it used for?

   b. Is the TOD timer used for task-switching? If not, is there a specific
      reason why this timer can't be used? I can't remember if you can get
      it to generate an interrupt or not. I think you can with an alarm.

   c. How does the CPU determine the time allotted to a task, specifically?
      Does it vary depending on the task load and the priority of the task,
      or is it fixed according to the priority?


| Michael Griffith                     | If I had an opinion it certainly   |
| griffith@eecs.ee.pdx.edu             | wouldn't be the same one as        |
| ...!tektronix!psueea!eecs!griffith   | Portland State University anyways. |

rsbx@cbmvax.commodore.com (Raymond S. Brand) (10/03/90)

In article <204@pdxgate.UUCP>, griffith@eecs.cs.pdx.edu (Michael Griffith) writes:
> I noticed that the system programmer's guide just says that CIA-A's B timer
> is used for various OS tasks and I was wondering:
> 
>    a. Is it used for the task-switching process? If not, what is it used for?
> 
>    b. Is the TOD timer used for task-switching? If not, is there a specific
>       reason why this timer can't be used? I can't remember if you can get
>       it to generate an interrupt or not. I think you can with an alarm.
> 
>    c. How does the CPU determine the time allotted to a task, specifically?
>       Does it vary depending on the task load and the priority of the task,
>       or is it fixed according to the priority?

The exact details are unimportant; what is important is the external behavior.

That out of the way, here are some details: Each task, each time it is started
by the scheduler is allowed a certain amount of time, a quantum, to run before
it is stopped and another allowed to run. If a task is blocked before using
all of the quantum, the remaining time is not carried over. As an implementation
detail, the timer.device notifies exec whenever an quantum has expired. The
quantum value for 2.0 is different than 1.3 and previous. The timer.device for
2.0 is new and uses all 3 timers/counter on cia-a; 1.3 timer.device used cia-a
tod counter and timer-b, timer-a belonged to the keyboard.

For those of you that are interested, the quantum value is stored in execbase.
Those of you that may want to change the quantum value will likely not find
any change in behavior of the system if you do. The reason for this is another
implementation detail: interrupts reschedule the tasks (this may change!).

					rsbx

> | Michael Griffith                     | If I had an opinion it certainly   |

------------------------------------------------------------------------
  Raymond S. Brand			rsbx@cbmvax.commodore.com
  Commodore-Amiga Engineering		...!uunet!cbmvax!rsbx
  1200 Wilson Drive			(215)-431-9100
  West Chester PA 19380			"Looking"
------------------------------------------------------------------------