All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] rt_heap_delete in asynchronous context
@ 2006-05-29  0:01 Nathaniel J Villaume
  2006-05-29 12:45 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 3+ messages in thread
From: Nathaniel J Villaume @ 2006-05-29  0:01 UTC (permalink / raw)
  To: xenomai

Hi, 

I have a simple user-space program (see below) that tries to
create a heap. If the heap already exists, then the program tries
to delete it. I have no other threads binding to the heap.

I can create, but not delete the heap. The error returned is
-EPERM. According to the API manual, this means the call occurred
in an asynchronous context. What does this mean, exactly? How
should I delete this heap? 

Any advice?

BTW, superb job on the documentation, it's made my learning curve
easy/straight-forward. 

Thanks,

Nate
/*************************************************/
/*! @file
  @brief 
  File shows how to allocate heap memory from user-space 
 */
#include "native/heap.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>

RT_HEAP heap;
const char hp_name[]="heap1";
size_t hp_size = 500000;
RT_HEAP_INFO hp_info;

/*Map error codes to human-readable strings*/
void xeno_error_lookup(const char* msg, int err);

int
main( void )
{
  int err = 0;
  err = rt_heap_create( &heap, hp_name, hp_size, H_SHARED);
  if (err)
  {
    printf("Couldn't create the heap\n");
    if (-EEXIST == err)
    { 
      printf("Deleting heap....\n");
      err = rt_heap_delete( &heap);
      if (err)
      {
        xeno_error_lookup("Couldn't delete heap.", err);
      }
    }
    exit(err);
  }
  return err;
}

void xeno_error_lookup(const char* msg, int err)
{
  char* pc=0;
  switch (err)
  {
    case -EINVAL:
      pc = "EINVAL"; 
      break;
    case -EIDRM:
      pc = "EIDRM"; 
      break;
    case -EPERM:
      pc = "EPERM"; 
      break;
  }
  printf("%s: %d => %s\n", msg, err, pc);
}




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-05-29 18:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-29  0:01 [Xenomai-help] rt_heap_delete in asynchronous context Nathaniel J Villaume
2006-05-29 12:45 ` Gilles Chanteperdrix
2006-05-29 18:19   ` Nathaniel J Villaume

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.