This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: how to implement EDF scheduling in eCos
Hello John and all!
On 27 January 2010 17:37, John Dallaway wrote:
> Try moving "edf_info" to be immediately following "priority" in
> CYG_SCHEDTHREAD_SCHEDIMP_MEMBERS so that the ordering of members in
> cyg_thread match the ordering in the Cyg_Thread class.
>
> I hope this helps...
>
> John Dallaway
> eCos maintiner
Tried, does not have any positive effect, output is the same.
Now, I want to describe all of my main steps for discussion. If there
is no solution, then, I think, I would better to move to another way
to *deliver* EDF specific information to schedule method.
So, in ktypes.h I have:
> typedef struct cyg_edf_info_t
> {
> cyg_count32 deadline;
> cyg_count32 wcet;
> cyg_count32 period;
> };
In kapidata.h I added:
> #elif defined(CYGSEM_KERNEL_SCHED_EDF)
> # define CYG_SCHEDTHREAD_SCHEDIMP_MEMBERS \
> cyg_thread *next; \
> cyg_thread *prev; \
> cyg_priority_t priority; /* current thread priority */ \
> struct cyg_edf_info_t * edf_info;
> #else
> # error Undefined scheduler type
In Cyg_SchedThread_Implementation class of edf.hxx I added *edf_info*:
> class Cyg_SchedThread_Implementation
> : public Cyg_DNode_T<Cyg_Thread>
> {
> friend class Cyg_Scheduler_Implementation;
> friend class Cyg_ThreadQueue_Implementation;
> protected:
> cyg_priority priority; // current thread priority
> struct cyg_edf_info_t * edf_info; // added by me
> ...
> }
In the constructor of Cyg_SchedThread_Implementation class at edf.cxx
file, I added followings:
> Cyg_SchedThread_Implementation::Cyg_SchedThread_Implementation
> (
> CYG_ADDRWORD sched_info
> )
> {
> CYG_REPORT_FUNCTION();
> CYG_REPORT_FUNCARG1("sched_info=%08x", sched_info);
> edf_info = (cyg_edf_info_t *) &sched_info;
> priority = (cyg_priority) edf_info->deadline;
>
> CYG_TRACE1(1, "edf_info->deadline = %d", edf_info->deadline);
> CYG_TRACE1(1, "edf_info->wcet = %d", edf_info->wcet);
> CYG_TRACE1(1, "edf_info->period = %d", edf_info->period);
> ...
> }
In my eCos application I am passing arguments in these way:
> #include <cyg/kernel/ktypes.h>
> ...
> void cyg_user_start(void)
> {
> struct cyg_edf_info_t my_edf_info_A = {4, 11, 12};
> struct cyg_edf_info_t my_edf_info_B = {5, 21, 22};
>
> cyg_thread_create((cyg_addrword_t) &my_edf_info_A, simple_program, (cyg_addrword_t) 0,
> "Thread A", (void *) stack[0], 32768,
> &simple_threadA, &thread_s[0]);
> cyg_thread_create((cyg_addrword_t) &my_edf_info_B, simple_program, (cyg_addrword_t) 1,
> "Thread B", (void *) stack[1], 32768,
> &simple_threadB, &thread_s[1]);
>
> printf("Threads are created\n");
> cyg_thread_resume(simple_threadA);
> cyg_thread_resume(simple_threadB);
> }
And output which I am getting is:
> TRACE: edf.cxx [602] Cyg_SchedThread_Implementation::Cyg_SchedThread_Implementation() 'edf_info->deadline = 31'
> TRACE: edf.cxx [603] Cyg_SchedThread_Implementation::Cyg_SchedThread_Implementation() 'edf_info->wcet = 0'
> TRACE: edf.cxx [604] Cyg_SchedThread_Implementation::Cyg_SchedThread_Implementation() 'edf_info->period = 0'
> TRACE: edf.cxx [602] Cyg_SchedThread_Implementation::Cyg_SchedThread_Implementation() 'edf_info->deadline = 10'
> TRACE: edf.cxx [603] Cyg_SchedThread_Implementation::Cyg_SchedThread_Implementation() 'edf_info->wcet = 0'
> TRACE: edf.cxx [604] Cyg_SchedThread_Implementation::Cyg_SchedThread_Implementation() 'edf_info->period = 0'
> TRACE: cstartup.cxx [91] void cyg_iso_c_start() 'Resuming cyg_libc_main_thread'
> TRACE: kapi.cxx [1238] void Cyg_Check_Structure_Sizes::Cyg_Check_Structure_Sizes() 'Size of C struct cyg_thread != size of C++ struct Cyg_Thread'
> ASSERT FAIL: <1> kapi.cxx [1250] Cyg_Check_Structure_Sizes::Cyg_Check_Structure_Sizes() Size check failed
> ASSERT FAIL: kapi.cxx [1250] Cyg_Check_Structure_Sizes::Cyg_Check_Structure_Sizes() Size check failed
I hope these codes and outputs could help to catch the bug. Any idea,
comment appreciated!
Regards,
Nodir.
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss