[PATCH] posix: Reimplement POSIX Key manager to use a red-black tree.

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Aug 2 06:38:55 UTC 2013


On 2013-08-02 03:03, Ashi wrote:
>
>         +  /** This field points to parent freechain node */
>         +  POSIX_Keys_Freechain_node *fc_node_ptr;
>
>
>     I don't think we need this fc_node_ptr.
>
> Do you mean use a 'Container' macro instead?

Not necessarily, see below.

>
>
>         +  /** This field is the POSIX key used as an rbtree key */
>         +  pthread_key_t key;
>         +  /** This field is the Thread id also used as an rbtree key */
>         +  Objects_Id thread_id;
>         +  /** This field points to the POSIX key value of specific thread */
>         +  void *value;
>         +}  POSIX_Keys_Rbtree_node;
>
>
>     I would call this POSIX_Keys_Key_value_pair.
>
>         +
>         +/**
>         + * @brief POSIX_Keys_Freechain is used in Freechain structure
>         + */
>         +typedef struct {
>         +    Freechain_Control super_fc;
>         +    size_t bump_count;
>         +} POSIX_Keys_Freechain;
>         +
>         +/**
>         + * @brief POSIX_Keys_Freechain_node is freechain node
>         + */
>         +struct POSIX_Keys_Freechain_node___struct {
>         +  Chain_Node ch_node;
>         +  POSIX_Keys_Rbtree_node rb_node;
>         +};
>
>
>     Why not use POSIX_Keys_Rbtree_node directly?
>
> Since every freechain node needs a Chain_Node in its first field. There is a
> Chain_Node in  POSIX_Keys_Rbtree_node, but it is used in each thread's key
> value chain. So I add a Chain_Node to POSIX_Keys_Rbtree_node.

The key value pairs on the free chain are unused, thus not part of other data 
structures.  So basically you can cast an unused object to any type provided it 
has enough storage.

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the devel mailing list