S.Ha.R.K. - http://shark.sssup.it --------------------------------- Porting old scheduling modules to the new scheduling module interface --------------------------------------------------------------------- by Paolo Gai, december 26, 2002 Introduction ------------ This document can be thought as a small step-by-step guide that should help in porting the S.Ha.R.K. scheduling modules to the new S.HA.R.K. interface. Basically, the new interface is simply a simplified version of the old interface. All the function names are changed to avoid some name collisions between kernel primitives and internal functions. As a result, the new function interface is as powerful as the old one, but is lighter (Scheduling modules file size shrank about 30%). What to do for converting an old module --------------------------------------- 1 - Take the old module. Add the include file #include Remove the include file #include 2 - change the following names using your editor's search&replace: level_scheduler --> public_scheduler level_guarantee --> public_guarantee task_create --> public_create task_detach --> public_detach task_end --> public_end task_eligible --> public_eligible task_dispatch --> public_dispatch task_epilogue --> public_epilogue task_activate --> public_activate task_insert --> public_unblock task_extract --> public_block task_endcycle --> public_message guest_create --> private_insert guest_end --> private_extract 3 - Changes in the behavior of some functions Some function have changed the interface: -> public_message now has this interface: int EDF_public_message(LEVEL l, PID p, void *m) You should probably add the int return value and the void *m. Add also this code at the end of the function: ------------------------------------------ jet_update_endcycle(); trc_logevent(TRC_ENDCYCLE,&exec_shadow); return 0; } ------------------------------------------ -> public create now does also the job of level_accept_task_model. For example, if we consider the standard EDF module, now the public_create start as following: ------------------------------------------------------------- static int EDF_public_create(LEVEL l, PID p, TASK_MODEL *m) { EDF_level_des *lev = (EDF_level_des *)(level_table[l]); HARD_TASK_MODEL *h; if (m->pclass != HARD_PCLASS) return -1; if (m->level != 0 && m->level != l) return -1; h = (HARD_TASK_MODEL *)m; if (!h->wcet || !h->mit) return -1; /* now we know that m is a valid model */ ... ------------------------------------------------------------ please note that pclass and level into the TASK_MODEL are now separated!!! 4 - Remove unuseful stuffs, correponding to the following fields of the level descriptor: level_name, level_code, level_version, level_accept_task_model, level_accept_guest_model, level_status, task_sleep, task_delay, guest_detach, guest_activate, guest_insert, guest_extract, guest_endcycle, guest_sleep, guest_delay 5 - queues QUEUES and IQUEUES no longer exist. Use IQUEUES. Typically, it is sufficient to substitute qq_* and q_* names with iq_* names. For example, q_timespec_insert becomes iq_timespec_insert. The initialization must be done with the code iq_init(&thequeue, &freedesc, 0); For a list of the IQUEUE's functions available look at include/kernel/iqueue.h 5 - request_time The task descriptor does no more have a request_time field. That field was typically used in the old task_activate task call, and in some other functions. To know what to do, simply look at how you used the request_time field. A lot of times it can simply be substituted with an automatic variable in the function where the field was used (as done, for example, in kernel/modules/edf.c). Otherwise, you can always put a request_time field in your level_des (as done, for example, in demos/cash/cash.c). 6 - kern_gettime(), kern_event_delete() The function ll_gettime now is called kern_gettime, and it has the same syntax of sys_gettime. Also, use the name kern_event_delete instead of event_delete. 7 - Register function The register function now should return a LEVEL. For example, the EDF register function now look as: kernel/modules/edf.c --------------------------------------------------- LEVEL EDF_register_level(int flags) { LEVEL l; /* the level that we register */ [...] return l; } --------------------------------------------------- Moreover, the internal code used to register a level is changed. Here is an example: -------------------------------------------------- LEVEL EDF_register_level(int flags) { LEVEL l; EDF_level_des *lev; PID i; l = level_alloc_descriptor(sizeof(EDF_level_des)); lev = (EDF_level_des *)level_table[l]; /* fill the standard descriptor */ lev->l.private_insert = EDF_private_insert; [...] lev->l.public_message = EDF_public_message; /* fill the EDF descriptor part */ [...] return l; } -------------------------------------------------------------- 8 - That's all!!! After you did all that, try to compile the module. Good Luck!!! PJ