Name
Processor Algorithms -- Interface for Algorithms.
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 ()
Find out which is the current algorithm.
init_CPU_algorithms ()
GSList* init_CPU_algorithms (void); |
Initializes the CPU algorithms code.
Mainly will call init functions for each algorithm.
register_CPU_algorithm ()
Each algorithm should call this function in it's initialization function
to register its algorithm struct.
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.
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.
reset_CPU_timer ()
gint reset_CPU_timer (void); |
Resets the "time unit" counter so we will have a full timeslice until
the next interupt.
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+.