Changes between Initial Version and Version 1 of InternalTricks


Ignore:
Timestamp:
Jun 30, 2006, 3:35:19 PM (18 years ago)
Author:
soujak
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • InternalTricks

    v1 v1  
     1= Internal tricks =
     2During real and deep developing time, we faced some obstacles seeming hard to
     3overcome, but we did. That is because a few tricks helped us.
     4
     5An early faced obstacle was the process queue tail pointer updating in `pcb.c`
     6module, avoiding to use a global-visible variable, but passing a parameter. To
     7do this, each involved function receives a pointer to that queue pointer (i.e. a
     8double pointer).
     9
     10We use the same hack on a different situation, writing `st.c` source, where we
     11enjoined double advantages. Maintaining a tree after insertion/removal
     12operations, means updating a couple of pointers, and so knowing their location.
     13Because of the fact that tree is
     14[wiki:DataStructures#a3.Semaphorebinarytree single-linked], going back the tree
     15becomes impossible, and so, each of such operations must be performed starting
     16one level higher in the hierarchy. Here another problem comes up: starting from
     17a node, which of its child is the wanted one? As pointed up above, we found just
     18one solution for both problem: using a pointer to the father's field
     19(`s_leftC`/`s_rightC`), which point to the target node.
     20
     21But, as you can see, there is another question: which is the ancestor of the
     22root element? If it does not exist, the solution just explained gets wrong and
     23need a small modification: the insertion of a dummy node, pointed to by
     24`semdRoot`, as root node, which makes the whole semaphore descriptors tree the
     25dummy's left-progeny.
     26
     27This change suggests another hack, in order to find a suitable place to store
     28the free list. It contains descriptors of each inactive semaphore: we linked it
     29as a list, using `s_rightC` field, avoiding memory space wastes.
     30
     31{{{
     32
     33 Semaphore Tree structure:
     34                ______
     35               |      |
     36               | HEAD |
     37               |______|
     38               .'   '.
     39           __.'       '.__
     40          |__|         |__|
     41        __.''.__         '.__
     42       |__|  |__|         |__|
     43
     44      |          |     |      |
     45       `--------'       `----'
     46          AST          Free List
     47
     48  Further details can be found directly in source code :)
     49
     50}}}