Memory Algorithms

Name

Memory Algorithms -- Interface for Algorithms.

Synopsis


struct      mem_algorithm_t;
mem_algorithm_t* get_MEM_current_algorithm  (void);
GSList*     init_MEM_algorithms             (void);
void        register_MEM_algorithm          (mem_algorithm_t *algorithm);

Description

Great effort has been devoted to making the addicion of new algorithms as easy as posible, here is documented what there is to know to be able to write your own algorithms.

Details

struct mem_algorithm_t

typedef struct {					/* This struct is all
							   that we know about
							   each algorithm */
	gchar * name;
	void (*select) (void);
	void (*unselect) (void);			/* These two functions
							   will be called before
							   and after the use of
							   an algorithm to let
							   it keep a low memory
							   usage when not in
							   use.*/
	GtkWidget * properties;				/* Each algorithm will
							   maintain it's own
							   properties widget.
							   NULL means "no
							   properties".  It
							   should be set to NULL
							   when destroyed. If
							   not destroyed in
							   "unselect" the system
							   will destroy it.*/
	void (*page_access) (gint pid, gint page);	/* lets the algorithm
							   keep track of page
							   accesses */
	gint (*select_frame) (void);			/* it should return a
							   frame to be assigned
							   when out of memory */
} mem_algorithm_t;


get_MEM_current_algorithm ()

mem_algorithm_t* get_MEM_current_algorithm  (void);

Find out which is the current algorithm.

Returns : the struct which descrives the current algorithm.


init_MEM_algorithms ()

GSList*     init_MEM_algorithms             (void);

Initializes the MEM algorithms code.

Mainly will call init functions for each algorithm.

Returns : a pointer to the algorithm structs linked list.


register_MEM_algorithm ()

void        register_MEM_algorithm          (mem_algorithm_t *algorithm);

Each algorithm should call this function in it's initialization function to register its algorithm struct.

algorithm : algorithm struct to register.