[Asterisk-Dev] scheduler

Martin Bangiev martin.bangiev at borsabg.com
Thu Mar 31 06:57:37 MST 2005


Hi all,
I'm trying to learn how to use the asterisk scheduler. For this purpose 
I wrote a simple application based on app_skel.
I added a global variable "static struct sched_context *sched;"
I do initialize the sched variable during loading module

int load_module(void) {
        int res;
        sched = sched_context_create();
        res = ast_register_application(app, mysched_exec, synopsis, 
descrip);
        return res;
}

and I have a simple function that I want to be scheduled:

static int test_sched(void *data) {
        ast_log(LOG_NOTICE, "test_sched...\n");
        return(0);
}

I add this function to the scheduler via a function called via extension

static int mysched_exec(struct ast_channel *chan, void *data) {
        LOCAL_USER_ADD(u);
        ast_sched_add(sched, 1000, test_sched, NULL);
        LOCAL_USER_REMOVE(u);
        return(res);
}

According to the description I have to see "test_sched..." in my CLI one 
second after the extension execute the mysched_exec function. But it 
seems to me like the function doesn't start at all.
Can someone tell me where am I wrong?

Thank You in advance :)
Martin



More information about the asterisk-dev mailing list