how to use chain in rtems?
Chan Kim
ckim at etri.re.kr
Tue Aug 25 12:11:10 UTC 2015
Through simple test I found the correct method.
ptr = (foo *)chain.Chain.Head.Node.next;
-------------------
int i;
rtems_chain_control chain;
foo *ptr;
rtems_chain_node *nptr;
rtems_chain_initialize_empty(&chain);
for (i=0; i< 10; i++) {
foo *bar = malloc (sizeof (foo));
if (!bar) return -1;
bar->number = 10-i;
printk("i=%d, bar = %x, bar->number = %d\n", i , bar, bar->number);
rtems_chain_append(&chain, &bar->node);
}
ptr = (foo *)chain.Chain.Head.Node.next;
printk("ptr = %x, ptr->number = %d\n", ptr, ptr->number);
rtems_chain_extract(ptr);
ptr = (foo *)chain.Chain.Head.Node.next;
printk("ptr->number = %d\n", ptr->number);
while (1) ;
---------------------result
i=0, bar = 201CEE48, bar->number = 10
i=1, bar = 201CEE60, bar->number = 9
i=2, bar = 201CEE78, bar->number = 8
i=3, bar = 201CEE90, bar->number = 7
i=4, bar = 201CEEA8, bar->number = 6
i=5, bar = 201CEEC0, bar->number = 5
i=6, bar = 201CEED8, bar->number = 4
i=7, bar = 201CEEF0, bar->number = 3
i=8, bar = 201CEF08, bar->number = 2
i=9, bar = 201CEF20, bar->number = 1
ptr = 201CEE48, ptr->number = 10
ptr->number = 9
Chan
보낸 사람 : "Chan Kim" <ckim at etri.re.kr>
보낸 날짜 : 2015-08-25 17:40:08 ( +09:00 )
받는 사람 : users at rtems.org <users at rtems.org>
참조 :
제목 : how to use chain in rtems?
Hello, all,
To use chain, I added rtems_chain_control queue; in the host structure.
Also, mrq has rtems_chain_node node; as the first element.
The method I used is
to initialize :
rtems_chain_initialize_empty(&host->queue);
to append mrq to the queue :
rtems_chain_append(&host->queue, &mrq->node);
to get the first node :
mrq = (struct mmc_request *)host->queue.Chain.Head.fill; (method 1)
mrq = (struct mmc_reequest *)rtems_chain_head(&host->queue); (method 2)
rtems_chain_extract(&mrq->node); (after method1 or method 2 I did this to distroy the node from the chain)
Is this correct method? I put WR mrq and when I was about to extract that, I enqueued RD mrq, then, when I read the first element,
it is RD mrq (using method 1) or some other value (using method 2).
Please someone tell me how to use it.
Thanks in advance.
Chan
_______________________________________________
users mailing list
users at rtems.org
http://lists.rtems.org/mailman/listinfo/users
More information about the users
mailing list