qos_memory.h File Reference

Space-independent memory allocation functions. More...

Go to the source code of this file.

Defines

#define qos_create(type)
 Create an instance of the supplied type.

Functions

void * qos_malloc (long size)
 Allocates a memory segment either in user-space or in kernel-space.
void * qos_malloc_named (long size, const char *name)
 Like qos_malloc(), but adds a name for the chunk useful when debugging.
void qos_free (void *ptr)
 Deallocates a memory segment.
int qos_mem_valid (void *ptr)
 Check if the supplied pointer is within allocated segments.
int qos_mem_clean (void)
 If memory check enabled, return 1 if all allocated memory chunks have been freed, and no chunk-related errors occurred ever during qos_malloc() / qos_free().

Detailed Description

Space-independent memory allocation functions.

These functions allocate and free a memory segment, independently of the space in which they are being compiled. For user-space, they map to malloc() and free(). For kernel-space, they map to kmalloc() and kfree().

Todo:

Check what are the proper flags to use with kmalloc().

These functions may be made static inline.

Definition in file qos_memory.h.


Define Documentation

#define qos_create ( type   ) 
Value:
({                                      \
      type *__ptr = qos_malloc_named(sizeof(type), #type);      \
      if (__ptr == NULL)                                        \
        qos_log_err("Could not allocate memory for " #type);    \
      __ptr;                                                    \
})

Create an instance of the supplied type.

Definition at line 48 of file qos_memory.h.

Referenced by qos_func_define(), qsup_add_group_constraints(), qsup_create_server(), rres_add(), rres_create_server(), and rres_init().


Function Documentation

void qos_free ( void *  ptr  ) 

Deallocates a memory segment.

Definition at line 176 of file qos_memory.c.

References qos_ll_free(), qos_log_crit, and qos_log_debug.

Referenced by qos_func_define(), qsup_cleanup(), qsup_create_server(), qsup_destroy_server(), rres_cleanup(), rres_del(), and rres_destroy_server().

void* qos_malloc ( long  size  ) 

Allocates a memory segment either in user-space or in kernel-space.

In case of no memory available returns 0.

Note:
Another possible implementation of allocation function can be:
   #define qos_malloc(x) do { x = xalloc(sizeof (*(x))); } while (0)

Definition at line 147 of file qos_memory.c.

References qos_malloc_named().

Referenced by get_user_info(), qres_setup_qsup_for_rres(), and qsup_add_user_constraints().

void* qos_malloc_named ( long  size,
const char *  name 
)

Like qos_malloc(), but adds a name for the chunk useful when debugging.

Definition at line 151 of file qos_memory.c.

References qos_ll_free(), qos_ll_malloc(), qos_log_crit, and qos_log_debug.

Referenced by qos_malloc().

int qos_mem_clean ( void   ) 

If memory check enabled, return 1 if all allocated memory chunks have been freed, and no chunk-related errors occurred ever during qos_malloc() / qos_free().

Definition at line 198 of file qos_memory.c.

References qos_log_debug.

Referenced by rres_cleanup_module().

int qos_mem_valid ( void *  ptr  ) 

Check if the supplied pointer is within allocated segments.

If memory chunks tracking is disabled, then this function returns always 1.

Definition at line 125 of file qos_memory.c.

Referenced by hrt_callback(), rres_any_blocked_task(), rres_any_ready_task(), rres_detach_task_nosched(), rres_schedule(), and timer_callback().

Generated on Mon Aug 2 22:39:17 2010 for qosres by  doxygen 1.6.3