Some problems in the implement of the supercore:

Bert doclzs at 21cn.com
Mon Dec 29 15:09:07 UTC 2003


Hi,here are some problems in the implement of the supercore.
i am urgent for your advice.
Thanks a lot in advance!

(1)the file "chain.inl"

RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Head(
  Chain_Control *the_chain
)
{
   return (Chain_Node *) the_chain;
}

i think it should be:

RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Head(
  Chain_Control *the_chain
)
{
   return (Chain_Node *) the_chain->first;
}

one of my colleagues think it should be:

RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Head(
  Chain_Control *the_chain
)
{
   return (Chain_Node *) &the_chain->first;
}

who is right? after all, the variable "first" is already
a pointer to a Chain_Node.

(2)the file "coresem.inl"

RTEMS_INLINE_ROUTINE void _CORE_semaphore_Seize_isr_disable(
  CORE_semaphore_Control  *the_semaphore,
  Objects_Id               id,
  boolean                  wait,
  Watchdog_Interval        timeout,
  ISR_Level               *level_p
) 
{ 
  Thread_Control *executing;
  ISR_Level       level = *level_p;
  
  executing = _Thread_Executing;
  executing->Wait.return_code = CORE_SEMAPHORE_STATUS_SUCCESSFUL;
  if ( the_semaphore->count != 0 ) {
    the_semaphore->count -= 1;
    _ISR_Enable( level );
    return;
  }

  if ( !wait ) {
    _ISR_Enable( level );
    executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT;
    return;
  }

  _Thread_Disable_dispatch();
  _Thread_queue_Enter_critical_section( &the_semaphore->Wait_queue );
  executing->Wait.queue          = &the_semaphore->Wait_queue;
  executing->Wait.id             = id;
  _ISR_Enable( level );

  _Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout );
  _Thread_Enable_dispatch();
}

Has it missed a piece of code "_ISR_Disable( level )"? if so,
where should it put?

(3)the file "heap.inl"

RTEMS_INLINE_ROUTINE Heap_Block *_Heap_User_block_at(
  void       *base
)
{
  unsigned32         offset;
 
  offset = *(((unsigned32 *) base) - 1);
  return _Heap_Block_at( base, -offset + -HEAP_BLOCK_USED_OVERHEAD);
}

what is the function of this? 
why "offset=*(((unsigned32 *) base) - 1)"?
what is meaning of the value "-offset + -HEAP_BLOCK_USED_OVERHEAD"?

(4)the file "heapallocate.c"

void *_Heap_Allocate(
  Heap_Control        *the_heap,
  unsigned32           size
)
{
......

  if ( size >= (-1 - HEAP_BLOCK_USED_OVERHEAD) )
    return( NULL );

  excess   = size % the_heap->page_size;
  the_size = size + the_heap->page_size + HEAP_BLOCK_USED_OVERHEAD;

......
}

It is sure that "size >= (-1 - HEAP_BLOCK_USED_OVERHEAD)", right?
what is meaning of the value "-1 - HEAP_BLOCK_USED_OVERHEAD"?
Is it necessary of the code
"the_size = size + the_heap->page_size + HEAP_BLOCK_USED_OVERHEAD;" ?
what is meaning of the value "the_heap->page_size + HEAP_BLOCK_USED_OVERHEAD"?

----------------------------------------------
ÍæÓÎÏ·Ó®ÊýÂëÏà»ú¡¢MP3¡¢UÅÌ 
http://mail.21cn.com/huodong/0310/ 
аÑÞ¾ªÈË ²¨°ÔÇǵ¤¡°°£¼°ÑÞºó¡±Ð´Õæ(ͼ) 
http://news.21cn.com/huahua/ 
¹ã¶«ADSLÓû§ÓÐ×ÅÊý£¬21CNÉÌÎñÓÊÃâ·ÑÁì 
http://mail.21cn.com/huodong/0310/ 
ÃÀ¹úÂôÒùÊÀ¼Ò½ÒÃØ:Å®¶ù¼ËŮĸÀÏð±(ͼ) 
http://news.21cn.com/social/ 





More information about the users mailing list