Anyone interested in EDF Scheduler?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Anyone interested in EDF Scheduler?

Yi Tang
Hi all,

I have checked the group and it seems we have already got talks about
edf scheduling. I have written a native version of edf for ecos,
implemented by using a sorted queue for task's absolute deadline, plan
to test it in the next few weeks.
For the deadline sorted queue, I utilize the Cyg_CList_T class to
implement that.

One problem I found for the edf is how to apply it to periodic task
model. For priority task, new job still got the same priority. But new
job in edf get different absolute deadline.

Thus I introduce two new thread controls:
complete()   -- showing thread complete current job, wait for next activate
release()      -- activate again for new job, update abs deadline
For the schdinfo init, I have these two functions in kapi

// init task deadline
void cyg_thread_edf_initddl(
        cyg_handle_t            thread,
        cyg_tick_count_t       ddl_init,
        cyg_bool        init_mode      //init mode abs or rel

// periodic task deadline
void cyg_thread_edf_perioddl(                          
        cyg_handle_t      thread,
        cyg_alarm         *alarm,
        cyg_alarm_t       *alarm_fn, // Call-back function
        cyg_tick_count_t  ddl_period    // relative value only
I noticed that the kapi already provide a deadline_wait function which
also set the start_time and run_time. But my view is that these two
values is not always needed in applications and it is really hard to
know in advance the exact run_time for a task job.
Please give some comments on my edf scheduler interface?

typedef cyg_uint64 cyg_deadline; // thread deadline type

class Cyg_SchedThread_Implementation
    : public Cyg_DNode_T<Cyg_Thread>
    friend class Cyg_Scheduler_Implementation;
    friend class Cyg_ThreadQueue_Implementation;

    cyg_deadline    peroid_ddl; // peroidic deadline
    cyg_deadline init_ddl; // init deadine
    cyg_deadline tmval; // Absolute deadine
    cyg_bool init_mode; // 1 = init abs deadline, 0 = init rel deadline
        cyg_bool release_flag;
    cyg_priority        priority;       // here just to pass compile
    Cyg_SchedThread_Implementation(CYG_ADDRWORD sched_info);

    // These are not applicable in a edf scheduler; placeholders:
    inline void rotate_queue( cyg_priority pri ) { };
    inline void to_queue_head( void ) { };
        void yield( void );

        void release( void );
        void complete( void );

        void set_init_deadline( cyg_deadline ddl_i, cyg_bool imode );

        void set_period_deadline( cyg_deadline ddl_p );


class Cyg_Scheduler_Implementation
    : public Cyg_Scheduler_Base
    friend class Cyg_SchedThread_Implementation;
    friend class Cyg_HardwareThread;
    friend void cyg_scheduler_set_need_reschedule();

// These pointers point to the head element of each list.
    static Cyg_Counter         *rtclock;      

// The run queue applies a sorted threads queue based on
// absolute deadline.
        Cyg_RunQueue run_queue;
        Cyg_Thread *idle_thread;
    Cyg_Scheduler_Implementation();     // Constructor
..... following same as other scheduler