thread data structure

Discussions and support about ChibiOS/RT, the free embedded RTOS.
Khan
Posts: 9
Joined: Thu Mar 02, 2017 12:54 pm
Has thanked: 1 time

thread data structure

Postby Khan » Tue Mar 14, 2017 7:43 pm

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.
}

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: thread data structure

Postby Giovanni » Tue Mar 14, 2017 11:00 pm

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

Khan
Posts: 9
Joined: Thu Mar 02, 2017 12:54 pm
Has thanked: 1 time

Re: thread data structure

Postby Khan » Wed Mar 15, 2017 12:52 am

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

Khan
Posts: 9
Joined: Thu Mar 02, 2017 12:54 pm
Has thanked: 1 time

Re: thread data structure

Postby Khan » Thu Mar 16, 2017 11:53 pm

Hi

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

Khan.

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: thread data structure

Postby Giovanni » Fri Mar 17, 2017 9:00 am

Preempt is the number of ticks until next round robin event, time is the time consumed by the thread in ticks.

Giovanni


Return to “ChibiOS/RT”

Who is online

Users browsing this forum: No registered users and 4 guests