* [Xenomai-help] task management, multi-thread, multi-core @ 2010-07-07 9:56 Everett Wang 2010-07-07 10:21 ` Gilles Chanteperdrix 0 siblings, 1 reply; 7+ messages in thread From: Everett Wang @ 2010-07-07 9:56 UTC (permalink / raw) To: xenomai Hi All, I am working on a navigation program that has two realtime tasks. One is a high priority one executed in a higher frequency. Another task runs about 1/10th of the first one, but requires substantially more CPU computations. I am using an atom board which has dual threads capability. I am worried that the second task can block the execution of the first one until it finishs all the calculations. Can this happen in a dual thread and/or dual core CPU? If yes, should I break the task two into small chunks and let the task one to send a trigger to execute one chunk at a time? I know it is not xenomai specific question and I have tried to read manual or other documents trying to figure it out. I have read that tasks require more resources than threads in Linux. The inter-threads communication is also more efficient than that of tasks. Are these also true for xenomai realtime OS? Should I create threads instead of tasks? Any suggestions are welcome. Thanks for reading. :-) Everett ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Xenomai-help] task management, multi-thread, multi-core 2010-07-07 9:56 [Xenomai-help] task management, multi-thread, multi-core Everett Wang @ 2010-07-07 10:21 ` Gilles Chanteperdrix 2010-07-07 10:49 ` Everett Wang 0 siblings, 1 reply; 7+ messages in thread From: Gilles Chanteperdrix @ 2010-07-07 10:21 UTC (permalink / raw) To: Everett Wang; +Cc: xenomai Everett Wang wrote: > Hi All, > > I am working on a navigation program that has two realtime tasks. One > is a high priority one executed in a higher frequency. Another task > runs about 1/10th of the first one, but requires substantially more > CPU computations. I am using an atom board which has dual threads > capability. I am worried that the second task can block the execution > of the first one until it finishs all the calculations. Can this > happen in a dual thread and/or dual core CPU? If yes, should I break > the task two into small chunks and let the task one to send a trigger > to > execute one chunk at a time? I know it is not xenomai specific > question and I have tried to read manual or other documents trying to > figure > it out. You did not tell us how was the priority of the second task, but since you told us that the first task was high priority, I have to guess that the second task is lower priority. On an uni-processor machine, the priorities are used by the scheduler to schedule your tasks, so, if a low priority task could prevent a high priority task from running, the scheduler would need to be fixed. On a multi-processor machine, you have to set the "affinity" of the tasks to pin the tasks on a given cpu. On each cpu, tasks are scheduled following their priorities. > > I have read that tasks require more resources than threads in Linux. > The inter-threads communication is also more efficient than that of > tasks. Are these also true for xenomai realtime OS? Should I create > threads instead of tasks? > > > Any suggestions are welcome. Thanks for reading. :-) task is an informal term which may mean process or thread depending on the context. So, I guess what you mean is "process" instead of task. The difference between processes and threads is that changing context between processes requires changing the memory mapping, which is an heavy operation. On the other hand, processes provide an isolation that threads do not provide. So, choosing threads or processes is not only a matter of performances (otherwise, we would all run Linux without MMU, since in that case, everything is essentially a thread). > > Everett > > _______________________________________________ > Xenomai-help mailing list > Xenomai-help@domain.hid > https://mail.gna.org/listinfo/xenomai-help > -- Gilles. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Xenomai-help] task management, multi-thread, multi-core 2010-07-07 10:21 ` Gilles Chanteperdrix @ 2010-07-07 10:49 ` Everett Wang 2010-07-07 11:24 ` Gilles Chanteperdrix 0 siblings, 1 reply; 7+ messages in thread From: Everett Wang @ 2010-07-07 10:49 UTC (permalink / raw) To: Gilles Chanteperdrix; +Cc: xenomai On Wed, Jul 7, 2010 at 6:21 PM, Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org> wrote: > Everett Wang wrote: >> Hi All, >> >> I am working on a navigation program that has two realtime tasks. One >> is a high priority one executed in a higher frequency. Another task >> runs about 1/10th of the first one, but requires substantially more >> CPU computations. I am using an atom board which has dual threads >> capability. I am worried that the second task can block the execution >> of the first one until it finishs all the calculations. Can this >> happen in a dual thread and/or dual core CPU? If yes, should I break >> the task two into small chunks and let the task one to send a trigger >> to >> execute one chunk at a time? I know it is not xenomai specific >> question and I have tried to read manual or other documents trying to >> figure >> it out. > > You did not tell us how was the priority of the second task, but since > you told us that the first task was high priority, I have to guess that > the second task is lower priority. > > On an uni-processor machine, the priorities are used by the scheduler to > schedule your tasks, so, if a low priority task could prevent a high > priority task from running, the scheduler would need to be fixed. > > On a multi-processor machine, you have to set the "affinity" of the > tasks to pin the tasks on a given cpu. On each cpu, tasks are scheduled > following their priorities. Thanks Gilles, you are so nice. Yes, the second task is at lower priority. I did state accurately. If the second task is running already, when the higher priority task is waiting for an outside event, then the event comes, the high priority task has to wait until the lower priority one to finish? >> >> I have read that tasks require more resources than threads in Linux. >> The inter-threads communication is also more efficient than that of >> tasks. Are these also true for xenomai realtime OS? Should I create >> threads instead of tasks? >> >> >> Any suggestions are welcome. Thanks for reading. :-) > > task is an informal term which may mean process or thread depending on > the context. So, I guess what you mean is "process" instead of task. The > difference between processes and threads is that changing context > between processes requires changing the memory mapping, which is an > heavy operation. On the other hand, processes provide an isolation that > threads do not provide. So, choosing threads or processes is not only a > matter of performances (otherwise, we would all run Linux without MMU, > since in that case, everything is essentially a thread). > You are right again. Sorry for the confusing. I meant process instead of the task. Do you mean that if I need memory isolation, I use process, if I am sure my code has no memory problem, I should choose thread for better performance? Or it is more complex than this? Have a nice day, Everett >> >> Everett >> >> _______________________________________________ >> Xenomai-help mailing list >> Xenomai-help@domain.hid >> https://mail.gna.org/listinfo/xenomai-help >> > > > -- > Gilles. > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Xenomai-help] task management, multi-thread, multi-core 2010-07-07 10:49 ` Everett Wang @ 2010-07-07 11:24 ` Gilles Chanteperdrix 2010-07-07 12:44 ` Everett Wang 0 siblings, 1 reply; 7+ messages in thread From: Gilles Chanteperdrix @ 2010-07-07 11:24 UTC (permalink / raw) To: Everett Wang; +Cc: xenomai Everett Wang wrote: > If the second task is running already, when the > higher priority > task is waiting for an outside event, then the event comes, the high > priority task > has to wait until the lower priority one to finish? No. Xenomai scheduler is preemptive: http://en.wikipedia.org/wiki/Preemptive_multitasking > Do you mean that if I need memory isolation, I use process, if I am sure my code > has no memory problem, I should choose thread for better performance? Or it > is more complex than this? You can never be sure that code has no memory problem. It is more complex than that, for instance, whether the threads are inter-dependent should be taken into account. -- Gilles. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Xenomai-help] task management, multi-thread, multi-core 2010-07-07 11:24 ` Gilles Chanteperdrix @ 2010-07-07 12:44 ` Everett Wang 2010-07-07 12:51 ` Gilles Chanteperdrix 0 siblings, 1 reply; 7+ messages in thread From: Everett Wang @ 2010-07-07 12:44 UTC (permalink / raw) To: Gilles Chanteperdrix; +Cc: xenomai On Wed, Jul 7, 2010 at 7:24 PM, Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org> wrote: > Everett Wang wrote: >> If the second task is running already, when the >> higher priority >> task is waiting for an outside event, then the event comes, the high >> priority task >> has to wait until the lower priority one to finish? > > No. Xenomai scheduler is preemptive: > http://en.wikipedia.org/wiki/Preemptive_multitasking That is why I thought to cut the lower priority but more CPU comsuming task into smaller pieces and only let it run for one piece at a time then wait so higher priority task don't have to wait. Once the higher priority task has done its thing, then send a trigger to the let the lower priority task to run one more chunk. Is this the right thing to do or I am totally off the track? Everett >> Do you mean that if I need memory isolation, I use process, if I am sure my code >> has no memory problem, I should choose thread for better performance? Or it >> is more complex than this? > > You can never be sure that code has no memory problem. It is more > complex than that, for instance, whether the threads are inter-dependent > should be taken into account. > > -- > Gilles. > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Xenomai-help] task management, multi-thread, multi-core 2010-07-07 12:44 ` Everett Wang @ 2010-07-07 12:51 ` Gilles Chanteperdrix 2010-07-07 14:28 ` Everett Wang 0 siblings, 1 reply; 7+ messages in thread From: Gilles Chanteperdrix @ 2010-07-07 12:51 UTC (permalink / raw) To: Everett Wang; +Cc: xenomai Everett Wang wrote: > On Wed, Jul 7, 2010 at 7:24 PM, Gilles Chanteperdrix > <gilles.chanteperdrix@xenomai.org> wrote: >> Everett Wang wrote: >>> If the second task is running already, when the >>> higher priority >>> task is waiting for an outside event, then the event comes, the high >>> priority task >>> has to wait until the lower priority one to finish? >> No. Xenomai scheduler is preemptive: >> http://en.wikipedia.org/wiki/Preemptive_multitasking > > That is why I thought to cut the lower priority but more CPU comsuming > task into smaller pieces and only let it run for one piece at a time > then wait so > higher priority task don't have to wait. Once the higher priority task has > done its thing, then send a trigger to the let the lower priority task to run > one more chunk. Is this the right thing to do or I am totally off the track? You are off the track. As I said, the scheduler is preemptive. -- Gilles. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Xenomai-help] task management, multi-thread, multi-core 2010-07-07 12:51 ` Gilles Chanteperdrix @ 2010-07-07 14:28 ` Everett Wang 0 siblings, 0 replies; 7+ messages in thread From: Everett Wang @ 2010-07-07 14:28 UTC (permalink / raw) To: Gilles Chanteperdrix; +Cc: xenomai On Wed, Jul 7, 2010 at 8:51 PM, Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org> wrote: > Everett Wang wrote: >> On Wed, Jul 7, 2010 at 7:24 PM, Gilles Chanteperdrix >> <gilles.chanteperdrix@xenomai.org> wrote: >>> Everett Wang wrote: >>>> If the second task is running already, when the >>>> higher priority >>>> task is waiting for an outside event, then the event comes, the high >>>> priority task >>>> has to wait until the lower priority one to finish? >>> No. Xenomai scheduler is preemptive: >>> http://en.wikipedia.org/wiki/Preemptive_multitasking >> >> That is why I thought to cut the lower priority but more CPU comsuming >> task into smaller pieces and only let it run for one piece at a time >> then wait so >> higher priority task don't have to wait. Once the higher priority task has >> done its thing, then send a trigger to the let the lower priority task to run >> one more chunk. Is this the right thing to do or I am totally off the track? > > You are off the track. As I said, the scheduler is preemptive. > Sorry. my mistake. This makes my life so much easier though. :-) Thanks Gilles, I have no more question. Have a nice day. > Gilles. > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-07-07 14:28 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-07-07 9:56 [Xenomai-help] task management, multi-thread, multi-core Everett Wang 2010-07-07 10:21 ` Gilles Chanteperdrix 2010-07-07 10:49 ` Everett Wang 2010-07-07 11:24 ` Gilles Chanteperdrix 2010-07-07 12:44 ` Everett Wang 2010-07-07 12:51 ` Gilles Chanteperdrix 2010-07-07 14:28 ` Everett Wang
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.