Changes between Initial Version and Version 1 of DataStructures


Ignore:
Timestamp:
May 30, 2006, 4:44:49 PM (18 years ago)
Author:
soujak
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DataStructures

    v1 v1  
     1= Data structures =
     2
     3A well-designed data structure allows a variety of critical operations to be
     4performed, using as little resources, both execution time and memory space, as
     5possible. Moreover a carefully chosen data structure will allow a more efficient
     6algorithm to be used; consequently such choice assume a primary importance in
     7this project.
     8[[BR]]
     9The two fundamental data structures on which Phase 1 layer is founded are lists
     10and trees, implemented in various ways, depending on the singular case
     11evaluations.
     12
     13Here below we are going to describe the two most significative flavour of them.
     14
     15 == 1. Linear single linked list ==
     16This simple data structure has been choosen for trivial structures
     17implementation. We are talking about lists of non-allocated PCBs or SDs:
     18respectively pcbFree and semdFree.
     19
     20In fact, because of element insertion and deletion may involve only the first
     21one, a stack with a ''O(1)'' computational cost is what we was looking for. And
     22is what we implemented with a linear single linked list, appreciating its
     23simplicity.
     24
     25
     26== 2. Circular double linked list ==
     27List management operations, such as element insertion and deletion, require
     28predecessor and successor updating. Because of this, a previous element pointer
     29(`p_prev`) is added to the PCB standard structure, performing these operations
     30scanning the list only once.
     31
     32Kaya Phase 1 will take advantage of double circularly linked list benefits in
     33every processes queue, which is widely used by operating system.
     34
     35
     36== 3. Semaphore binary tree ==
     37The importance of the '''choice''' of data structure increases directly with the
     38performance relevance and for semaphore descriptors management becomes a primary
     39goal. That is because semaphores queue's phisical address is obfuscated in a
     40higher level view, so Phase 1 layer must encapsulate the association between
     41semaphore address (semAdd) and its queue into the Semaphore descriptors (SDs).
     42
     43Such association must be searched between them and if they are managed in a sorted
     44structure computational costs decrease, avoiding scanning everyone. For this
     45reason we opted for a data structure that is more complex and difficult to
     46mantain but, on the other hand, is more performant and scalable: a binary search
     47tree.
     48
     49Let us show in detail a BSTs '''comparison''' with sorted list.
     50[[BR]]
     51The major part of mantainence costs depends on the fact that it is sorted and,
     52consequently, on the search cost. In fact, while a list search costs ''O(n)'', a
     53binary tree takes only ''O(log(n))'', because of the number of scanned elements
     54is at most equal to the tree height. By the way, input distribution influences
     55BST's height in a determining way, deciding tree balance, making ''O(log(n))''
     56an estimate of the average case cost. In particularly adverse situations BSTs
     57collapse into a ''f**ked/s**t'' list.
     58[[BR]]
     59Summing up, in order to appreciate BSTs performance improvements and scalability,
     60input cardinality should be sufficiently large and well-distributed.
     61
     62Like often happens, performance and '''memory usage''' risk to collide and a good
     63compromise is needed.
     64[[BR]]
     65Therefore we tried to limit wastes, just single-linking the tree with `s_rightC`
     66and `s_leftC` pointers, increasing module complexity and consequent
     67implementation and mantainance [wiki:doc/devel difficulties].