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!
I think finally I got out of previous problem, facing another one...
But, John, I thank you very much, for being together all the time!
Now I have more interesting picture and one *puzzle*.
Let me explain picture first, next I will explain *puzzle*.
As the last time In ktypes.h I have:
> typedef cyg_count32 cyg_priority; // priority value
> 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_sched_edf_info_t *edf_info; \
> CYG_SCHEDTHREAD_CPU_MEMBER \
> CYG_SCHEDTHREAD_TIMESLICE_MEMBER \
> CYG_SCHEDTHREAD_TIMESLICE_ENABLED_MEMBER
> #else ...
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_sched_edf_info_t *edf_info; // added by me
> ...
> }
In my eCos application I am passing arguments in this way:
> #include <cyg/kernel/ktypes.h>
> ...
> void cyg_user_start(void)
> {
> ? ? ? struct cyg_edf_info_t my_edf_info_A = {4, 11, 12};
>
> ? ? ? cyg_thread_create((cyg_addrword_t) &my_edf_info_A, simple_program, (cyg_addrword_t) 0,
> ? ? ? ? ? ? ? "Thread A", (void *) stack[0], 4096,
> ? ? ? ? ? ? ? ?&simple_threadA, &thread_s[0]);
> ? ? ? printf("Threads are created\n");
> ? ? ? cyg_thread_resume(simple_threadA);
> }
Now, *puzzle*. Depending on my code in the constructor of the
Cyg_SchedThread_Implementation class at edf.cxx I have two different
outputs.
In the first scenario (result is the same as in the previous post,
*priority* with *edf_info->deadline* value):
> Cyg_SchedThread_Implementation::Cyg_SchedThread_Implementation
> (
> ? ?CYG_ADDRWORD sched_info
> )
> {
> edf_info = (cyg_sched_edf_info_t *) sched_info;
> CYG_TRACE1(1, "deadline = %d", edf_info->deadline);
> CYG_TRACE1(1, "wcet = %d", edf_info->wcet);
> CYG_TRACE1(1, "period = %d", edf_info->period);
> priority = (cyg_priority) edf_info->deadline; // important
> CYG_TRACE1(1, "Priority = %d ", priority);
> ...
> }
Output is:
> TRACE: edf.cxx [590] Cyg_SchedThread_Implementation::Cyg_SchedThread_Implementation() ? 'deadline = 16688624'
> TRACE: edf.cxx [591] Cyg_SchedThread_Implementation::Cyg_SchedThread_Implementation() ? 'wcet = 15304688'
> TRACE: edf.cxx [592] Cyg_SchedThread_Implementation::Cyg_SchedThread_Implementation() ? 'period = 15691760'
> TRACE: edf.cxx [594] Cyg_SchedThread_Implementation::Cyg_SchedThread_Implementation() ? 'priority = 16688624'
> ASSERT FAIL: <1> edf.cxx [211] Cyg_Scheduler_Implementation::add_thread() ?Priority out of range!
In the second scenario (just changing *priority* assign value to *sched_info*):
> Cyg_SchedThread_Implementation::Cyg_SchedThread_Implementation
> (
> ? ?CYG_ADDRWORD sched_info
> ) {
> edf_info = (cyg_sched_edf_info_t *) sched_info;
> CYG_TRACE1(1, "deadline= %d", edf_info->deadline);
> CYG_TRACE1(1, "wcet = %d", edf_info->wcet);
> CYG_TRACE1(1, "period = %d", edf_info->period);
> priority = (cyg_priority) sched_info; // important
> CYG_TRACE1(1, "Priority = %d ", priority);
> ...
> }
Output is:
> TRACE: prestart.cxx [77] void cyg_prestart() 'This is the system default cyg_prestart()'
> TRACE: pkgstart.cxx [87] void cyg_package_start() 'This is the system default cyg_package_start()'
> TRACE: edf.cxx [590] Cyg_SchedThread_Implementation::Cyg_SchedThread_Implementation() ? 'deadline = 4'
> TRACE: edf.cxx [591] Cyg_SchedThread_Implementation::Cyg_SchedThread_Implementation() ? 'wcet = 11'
> TRACE: edf.cxx [592] Cyg_SchedThread_Implementation::Cyg_SchedThread_Implementation() ? 'period = 12'
> TRACE: edf.cxx [594] Cyg_SchedThread_Implementation::Cyg_SchedThread_Implementation() ? 'priority = 1162644'
> Threads are created
> ASSERT FAIL: <1> edf.cxx [211] Cyg_Scheduler_Implementation::add_thread() ?Priority out of range!
I think, the value to which *edf_info->deadline* pointing is changing
depending on which value has the *priority*. But, I don't no why?
Can anyone help me to find an answer?
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