Changes between Version 1 and Version 2 of InternalTricks


Ignore:
Timestamp:
Jun 30, 2006, 9:26:02 PM (18 years ago)
Author:
gnappo
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • InternalTricks

    v1 v2  
    11= Internal tricks =
     2
    23During real and deep developing time, we faced some obstacles seeming hard to
    34overcome, but we did. That is because a few tricks helped us.
     5
     6== Phase 1 ==
    47
    58An early faced obstacle was the process queue tail pointer updating in `pcb.c`
     
    3033
    3134{{{
    32 
    33  Semaphore Tree structure:
     35 ------------------------------------------------------------------------------
     36|                          Semaphore Tree structure                            |
     37 ------------------------------------------------------------------------------
    3438                ______
    3539               |      |
     
    4751
    4852  Further details can be found directly in source code :)
     53}}}
    4954
    50 }}}
     55== Phase 2 ==
     56
     57Kaya OS provides a system call which offers to the caller the
     58possibility to wait until the next pseudo-clock tick. This clock
     59wakes up sleeping process every 100 milliseconds.
     60The best way to make this clock accurate is to use the interval
     61timer, which is therefore used in two different manners. So we
     62had to distinguish between the pseudo-clock use and the classic
     63preemption trigger use. Moreover we had to guarantee the
     64accuracy of length of time-quantum assigned to scheduled
     65processes. The answer to both issues is a time-credit system.
     66[[BR]]
     67Time credits, as you can easily see, solves the problem about
     68time slices. And the problem about the distinction of
     69interval-timer uses, too. If there are some credits, it means
     70that the current process was dispatched for a time lesser than
     71the quantum that was assigned by the scheduler. The dispatcher
     72is conscious of time-credit system and restores time losses.
     73
     74There is another situation where our implementation differs from
     75the expected one. The classic implementation of
     76'''semaphores''', need a value adjustment when terminating a
     77waiting process. Instead of this, we opted to change the value
     78only if needed, that means the `passeren()` subtracts only if
     79non-blocking and the `verhogen()` adds only when no process is
     80blocked.
     81There are several little optimization limiting wastes of cpu
     82time and memory usage. They do not deserve a deep explanation
     83but they must be mentioned:
     84 * '''Direct passup''': external exception-handlers (loaded by
     85   internal ones) returns the control directly to the process
     86   which raised the exception.
     87 * '''Iterative `TERMTHREAD`''': process termination means
     88   termination of its progeny. Instead of a recursive call, we
     89   preferred to first breadth-visit the whole sub-tree and then
     90   kill generation after generation.... muahuahuahuah!
     91   <pedice>Search for the mortuary among the code.</pedice>
     92 * '''Exception handler functions''': An unexpected benefit of
     93   modularization avoided exceptions raising after errors or
     94   abnormal situations. We opted for a direct function-call
     95   strategy, which clearly minimizes the over-head caused by
     96   these recursion, reducing the number of context switches.
     97 * '''Idle''': thumbs twiddling it is implemented without waste
     98   a whole process control block. A dummy-loop function is more
     99   than enough, so we automagically set the interval timer up in
     100   order to ring when it is time to pseudo-tick.