Processor Algorithms

Name

Processor Algorithms -- Interface for Algorithms.

Synopsis


struct      cpu_algorithm_t;
cpu_algorithm_t* get_CPU_current_algorithm  (void);
GSList*     init_CPU_algorithms             (void);
gint        register_CPU_algorithm          (cpu_algorithm_t *algorithm);
gint        deallocate_algorithm_private_data
                                            (proc_queue_t proc_list);
gint        set_CPU_heart_beat              (gint freq);
gint        reset_CPU_timer                 (void);

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 cpu_algorithm_t

typedef struct { /*This struct is all that we know about each algorithm*/
	gchar * name;				
	gint (*select) (void);
	gint (*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.*/
	gint (*clock) (void);			/* timer interrupt. */
	gint (*select_proc) (proc_t *proc);	/* notifies the algorithm of a
						   process selection by the
						   user */
	GtkWidget * process_properties;
	GtkWidget * properties;			/* Each algorithm will maintain
						   it's own properties widgets.
						   NULL means "no properties".
						   They should be set to NULL
						   when destroyed. If not
						   destroyed in "unselect" the
						   system will destroy them.*/
	gint (*init_proc) (proc_t *proc);	/* This function should allocate
						   and initialice algorith data
						   and anything else to get
						   a new process going, like
						   sticking it into a queue. */
	gint (*end_proc) (proc_t *proc);	/* This function should free the
						   algorithm specific data of
						   proc but should not take it
						   out of its queue */
	gint (*event) (proc_t *proc);		/* This function is called when
						   ever a process gets waked up
						   by an event and we have to
						   put it in some queue. */
	gint (*next) (proc_t *proc);		/* This function is called when
						   ever the current process gets
						   suspended waiting for some
						   event and we have to choose
						   another one to run.
						   It receives the suspended
						   process as argument just in
						   case its needed. */
} cpu_algorithm_t;


get_CPU_current_algorithm ()

cpu_algorithm_t* get_CPU_current_algorithm  (void);

Find out which is the current algorithm.

Returns : the struct which descrives the current algorithm.


init_CPU_algorithms ()

GSList*     init_CPU_algorithms             (void);

Initializes the CPU algorithms code.

Mainly will call init functions for each algorithm.

Returns : a pointer to the algorithm structs linked list


register_CPU_algorithm ()

gint        register_CPU_algorithm          (cpu_algorithm_t *algorithm);

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

algorithm : algorithm struct to register.
Returns : nothing important.


deallocate_algorithm_private_data ()

gint        deallocate_algorithm_private_data
                                            (proc_queue_t proc_list);

This function uses the algorithm's private data of each process as argument to g_free.

This is for convinience of algorithm writers.

proc_list : queue of processes.
Returns : nothing important.


set_CPU_heart_beat ()

gint        set_CPU_heart_beat              (gint freq);

Set timer interrupt frequency. Which means, the calling frequency of algorithm function clock.

Zero means that the timer interupt is not desired.

freq : new frequency in "time units".
Returns : nothing important.


reset_CPU_timer ()

gint        reset_CPU_timer                 (void);

Resets the "time unit" counter so we will have a full timeslice until the next interupt.

Returns : nothing important.

See Also

Process Queues

How to inspect process queues.

Processor Simulation

How simulation works.

Property Widget Facility

How to hadle numerical algorithm properties with the user without learning GTK+.