Page 1 of 1

thread data structure

Posted: Tue Mar 14, 2017 7:43 pm
by Khan
Hi
I'm trying to implement data structure in scheduler, but when I initialize it in:
chschd.c
void _scheduler_init(void) {
ch.rlist.dl = (systime_t)50;
}
I get big number in:
thread_t *chSchReadyI(thread_t *tp) {
cp = (thread_t *)&ch.rlist.queue;
cp->dl //-> this is not 50
}

chschd.h
struct ch_thread{[/b]
systime_t dl;
}

struct ch_ready_list{
systime_t dl;
}
I thing that problem is in allocate memory but I don't find out issue.
When I try:
chschd.c
void _scheduler_init(void) {
thread_t *cp;
queue_init(&ch.rlist.queue);

ch.rlist.prio = 0;
ch.rlist.dl = (systime_t)50;
cp = (thread_t *)&ch.rlist.queue;
cp->dl -> this is 0 and not 50.
}

Re: thread data structure

Posted: Tue Mar 14, 2017 11:00 pm
by Giovanni
I can only point out that the first fields of the thread structure and ready list structure must be the same because list handling, apparently this is not the case in your modification.

Giovanni

Re: thread data structure

Posted: Wed Mar 15, 2017 12:52 am
by Khan
Hi,

When i copied lines in structures (thread, ready list), it solved my problem. Can you explain it to me ? I thought that in c it does no matter how is structure written. Is it because I cast it in pointer of thread like: cp = (thread_t *)&ch.rlist.queue;

Thank you

Khan

Re: thread data structure

Posted: Thu Mar 16, 2017 11:53 pm
by Khan
Hi

What is difference between preempt and time in thread data structure ?

Khan.

Re: thread data structure

Posted: Fri Mar 17, 2017 9:00 am
by Giovanni
Preempt is the number of ticks until next round robin event, time is the time consumed by the thread in ticks.

Giovanni