All of lore.kernel.org
 help / color / mirror / Atom feed
* Mode Switch
@ 2021-02-15 13:00 Leandro Bucci
       [not found] ` <358306354.8105980.1613394904650.JavaMail.zimbra@wolfram.com>
  0 siblings, 1 reply; 12+ messages in thread
From: Leandro Bucci @ 2021-02-15 13:00 UTC (permalink / raw)
  To: xenomai

hi, I can't understand why if I use the memcpy function on Xenomai I don't
have any mode switch. Is there a function that copies two arrays and
generates a mode switch?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Mode Switch
       [not found] ` <358306354.8105980.1613394904650.JavaMail.zimbra@wolfram.com>
@ 2021-02-15 13:16   ` Leandro Bucci
  2021-02-15 13:46     ` Per Oberg
  0 siblings, 1 reply; 12+ messages in thread
From: Leandro Bucci @ 2021-02-15 13:16 UTC (permalink / raw)
  To: Per Oberg, xenomai

Yes I want a mode switch happened, thank for your answer

Il lun 15 feb 2021, 14:15 Per Oberg <pero@wolfram.com> ha scritto:

> ----- Den 15 feb 2021, på kl 14:00, xenomai xenomai@xenomai.org skrev:
>
> > hi, I can't understand why if I use the memcpy function on Xenomai I
> don't
> > have any mode switch. Is there a function that copies two arrays and
> > generates a mode switch?
>
>
> I don't think I understand your question.
>
> I don't see why copying data from one memory location to another would
> cause a mode switch. Not unless you use cause a page-fault or something ...
>
> Or, do you WANT a mode switch to happen ?
>
> Per Öberg
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Mode Switch
  2021-02-15 13:16   ` Leandro Bucci
@ 2021-02-15 13:46     ` Per Oberg
  2021-02-15 13:52       ` Leandro Bucci
  0 siblings, 1 reply; 12+ messages in thread
From: Per Oberg @ 2021-02-15 13:46 UTC (permalink / raw)
  To: xenomai


----- Den 15 feb 2021, på kl 14:16, Leandro Bucci guestleandro11@gmail.com skrev:

> Yes I want a mode switch happened, thank for your answer

> Il lun 15 feb 2021, 14:15 Per Oberg < [ mailto:pero@wolfram.com |
> pero@wolfram.com ] > ha scritto:

>> ----- Den 15 feb 2021, på kl 14:00, xenomai [ mailto:xenomai@xenomai.org |
>> xenomai@xenomai.org ] skrev:

>> > hi, I can't understand why if I use the memcpy function on Xenomai I don't
>> > have any mode switch. Is there a function that copies two arrays and
>> > generates a mode switch?

>> I don't think I understand your question.

>> I don't see why copying data from one memory location to another would cause a
>> mode switch. Not unless you use cause a page-fault or something ...

>> Or, do you WANT a mode switch to happen ?

I feel like I am missing context here, perhaps you have discussed this recently in another thread?

But, if you are using Alchemy skin, could you perhaps do : rt_task_set_mode(), see [1] below, with the correct flags ? 

>> Per Öberg

[1] https://xenomai.org/documentation/xenomai-3/html/xeno3prm/group__alchemy__task.html#ga915e7edfb0aaddb643794d7abc7093bf

Best regards
Per Öberg


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Mode Switch
  2021-02-15 13:46     ` Per Oberg
@ 2021-02-15 13:52       ` Leandro Bucci
  2021-02-15 13:57         ` Julien Blanc
  0 siblings, 1 reply; 12+ messages in thread
From: Leandro Bucci @ 2021-02-15 13:52 UTC (permalink / raw)
  To: Per Oberg; +Cc: xenomai

What I want is to have a function that generates me mode switches

Il giorno lun 15 feb 2021 alle ore 14:46 Per Oberg <pero@wolfram.com> ha
scritto:

>
> ----- Den 15 feb 2021, på kl 14:16, Leandro Bucci guestleandro11@gmail.com
> skrev:
>
> > Yes I want a mode switch happened, thank for your answer
>
> > Il lun 15 feb 2021, 14:15 Per Oberg < [ mailto:pero@wolfram.com |
> > pero@wolfram.com ] > ha scritto:
>
> >> ----- Den 15 feb 2021, på kl 14:00, xenomai [ mailto:
> xenomai@xenomai.org |
> >> xenomai@xenomai.org ] skrev:
>
> >> > hi, I can't understand why if I use the memcpy function on Xenomai I
> don't
> >> > have any mode switch. Is there a function that copies two arrays and
> >> > generates a mode switch?
>
> >> I don't think I understand your question.
>
> >> I don't see why copying data from one memory location to another would
> cause a
> >> mode switch. Not unless you use cause a page-fault or something ...
>
> >> Or, do you WANT a mode switch to happen ?
>
> I feel like I am missing context here, perhaps you have discussed this
> recently in another thread?
>
> But, if you are using Alchemy skin, could you perhaps do :
> rt_task_set_mode(), see [1] below, with the correct flags ?
>
> >> Per Öberg
>
> [1]
> https://xenomai.org/documentation/xenomai-3/html/xeno3prm/group__alchemy__task.html#ga915e7edfb0aaddb643794d7abc7093bf
>
> Best regards
> Per Öberg
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Mode Switch
  2021-02-15 13:52       ` Leandro Bucci
@ 2021-02-15 13:57         ` Julien Blanc
  2021-02-15 14:06           ` Leandro Bucci
  0 siblings, 1 reply; 12+ messages in thread
From: Julien Blanc @ 2021-02-15 13:57 UTC (permalink / raw)
  To: xenomai

Le lundi 15 février 2021 à 14:52 +0100, Leandro Bucci via Xenomai a
écrit :
> What I want is to have a function that generates me mode switches

__STD(nanosleep)(timeout, NULL) with a zero timeout should do it.

and you can use any switch-primary call to go back to primary mode.

Regards,

Julien

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Mode Switch
  2021-02-15 13:57         ` Julien Blanc
@ 2021-02-15 14:06           ` Leandro Bucci
  0 siblings, 0 replies; 12+ messages in thread
From: Leandro Bucci @ 2021-02-15 14:06 UTC (permalink / raw)
  To: Julien Blanc; +Cc: xenomai

perfect it works! Thanks!

Il giorno lun 15 feb 2021 alle ore 14:57 Julien Blanc via Xenomai <
xenomai@xenomai.org> ha scritto:

> Le lundi 15 février 2021 à 14:52 +0100, Leandro Bucci via Xenomai a
> écrit :
> > What I want is to have a function that generates me mode switches
>
> __STD(nanosleep)(timeout, NULL) with a zero timeout should do it.
>
> and you can use any switch-primary call to go back to primary mode.
>
> Regards,
>
> Julien
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Mode Switch
  2021-01-03 22:22       ` Leandro Bucci
@ 2021-01-03 22:57         ` steve freyder
  0 siblings, 0 replies; 12+ messages in thread
From: steve freyder @ 2021-01-03 22:57 UTC (permalink / raw)
  To: Leandro Bucci, xenomai

OK, so then my theory about it having to do with launching a printf 
helper must be wrong (maybe that only happens on the original thread).  
I don't recall whether you had a flush call after your printf though...

On 1/3/2021 4:22 PM, Leandro Bucci wrote:
> I understand, but it's strange because if I do a printf inside the 
> task I always have MSW = 2.  Yes maybe Philippe can help.  Thank you too
>
> Il dom 3 gen 2021, 23:16 steve freyder <steve@freyder.net 
> <mailto:steve@freyder.net>> ha scritto:
>
>     Might need some help from Philippe on this one but my thinking
>     says that thread creation happens in secondary mode, so there's
>     gotta be at least *one* mode switch on the way to becoming a
>     cobalt thread running in primary mode, perhaps the second one has
>     to do with launching the background printf() helper thread?
>
>
>
>     On 1/3/2021 4:08 PM, Leandro Bucci wrote:
>>     But in the task I don't do any printf, how is it possible that
>>     MSW = 2?
>>
>>     Il dom 3 gen 2021, 23:00 steve freyder <steve@freyder.net
>>     <mailto:steve@freyder.net>> ha scritto:
>>
>>         Each time I would do something like this:
>>
>>
>>         printf(...) ;
>>
>>         fflush(stdout) ;
>>
>>         rt_task_sleep(1e9/5) ;
>>
>>         rt_task_inquire(...) ;
>>
>>
>>         msw incremented by 1, csw would increment by 2.
>>
>>
>>         On 1/3/2021 2:29 PM, Leandro Bucci via Xenomai wrote:
>>>         Hi, I have a strange behavior regarding the "mode switch".
>>>         In the attached code, the task should never switch to the Linux domain, but
>>>         instead I have a value of MSW = 2.
>>>         How is it possible?
>>>         Even if I do a printf in the task I always get MSW = 2.
>>>         I can't understand where the problem is.
>>>
>>>         #include <stdio.h>
>>>         #include <stdlib.h>
>>>         #include <unistd.h>
>>>         #include <alchemy/task.h>
>>>         #include <alchemy/timer.h>
>>>
>>>         RT_TASK task;
>>>         RT_TASK_INFO info;
>>>
>>>         void task_body(void *arg)
>>>         {
>>>         rt_task_inquire(NULL, &info);
>>>         }
>>>
>>>         int main()
>>>         {
>>>         int err;
>>>
>>>         err = rt_task_create(&task, "mytask", 0, 1, 0);
>>>         if (err != 0){
>>>         fprintf(stderr, "failed to create task\n");
>>>         exit(EXIT_FAILURE);
>>>         }
>>>
>>>         err = rt_task_start(&task, &task_body, NULL);
>>>         if (err != 0){
>>>         fprintf(stderr, "failed to start task\n");
>>>         exit(EXIT_FAILURE);
>>>         }
>>>
>>>         sleep(5); //sleep for 5 seconds
>>>
>>>         printf("mode switch = %d\n", (int)(info.stat.msw));
>>>
>>>         exit(EXIT_SUCCESS);
>>>         }
>>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Mode Switch
  2021-01-03 22:16     ` steve freyder
@ 2021-01-03 22:22       ` Leandro Bucci
  2021-01-03 22:57         ` steve freyder
  0 siblings, 1 reply; 12+ messages in thread
From: Leandro Bucci @ 2021-01-03 22:22 UTC (permalink / raw)
  To: steve freyder, xenomai

I understand, but it's strange because if I do a printf inside the task I
always have MSW = 2.  Yes maybe Philippe can help.  Thank you too

Il dom 3 gen 2021, 23:16 steve freyder <steve@freyder.net> ha scritto:

> Might need some help from Philippe on this one but my thinking says that
> thread creation happens in secondary mode, so there's gotta be at least
> *one* mode switch on the way to becoming a cobalt thread running in primary
> mode, perhaps the second one has to do with launching the background
> printf() helper thread?
>
>
>
> On 1/3/2021 4:08 PM, Leandro Bucci wrote:
>
> But in the task I don't do any printf, how is it possible that MSW = 2?
>
> Il dom 3 gen 2021, 23:00 steve freyder <steve@freyder.net> ha scritto:
>
>> Each time I would do something like this:
>>
>>
>> printf(...) ;
>>
>> fflush(stdout) ;
>>
>> rt_task_sleep(1e9/5) ;
>>
>> rt_task_inquire(...) ;
>>
>>
>> msw incremented by 1, csw would increment by 2.
>>
>>
>> On 1/3/2021 2:29 PM, Leandro Bucci via Xenomai wrote:
>>
>> Hi, I have a strange behavior regarding the "mode switch".
>> In the attached code, the task should never switch to the Linux domain, but
>> instead I have a value of MSW = 2.
>> How is it possible?
>> Even if I do a printf in the task I always get MSW = 2.
>> I can't understand where the problem is.
>>
>> #include <stdio.h>
>> #include <stdlib.h>
>> #include <unistd.h>
>> #include <alchemy/task.h>
>> #include <alchemy/timer.h>
>>
>> RT_TASK task;
>> RT_TASK_INFO info;
>>
>> void task_body(void *arg)
>> {
>> rt_task_inquire(NULL, &info);
>> }
>>
>> int main()
>> {
>> int err;
>>
>> err = rt_task_create(&task, "mytask", 0, 1, 0);
>> if (err != 0){
>> fprintf(stderr, "failed to create task\n");
>> exit(EXIT_FAILURE);
>> }
>>
>> err = rt_task_start(&task, &task_body, NULL);
>> if (err != 0){
>> fprintf(stderr, "failed to start task\n");
>> exit(EXIT_FAILURE);
>> }
>>
>> sleep(5); //sleep for 5 seconds
>>
>> printf("mode switch = %d\n", (int)(info.stat.msw));
>>
>> exit(EXIT_SUCCESS);
>> }
>>
>>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Mode Switch
  2021-01-03 22:08   ` Leandro Bucci
@ 2021-01-03 22:16     ` steve freyder
  2021-01-03 22:22       ` Leandro Bucci
  0 siblings, 1 reply; 12+ messages in thread
From: steve freyder @ 2021-01-03 22:16 UTC (permalink / raw)
  To: Leandro Bucci, xenomai

Might need some help from Philippe on this one but my thinking says that 
thread creation happens in secondary mode, so there's gotta be at least 
*one* mode switch on the way to becoming a cobalt thread running in 
primary mode, perhaps the second one has to do with launching the 
background printf() helper thread?



On 1/3/2021 4:08 PM, Leandro Bucci wrote:
> But in the task I don't do any printf, how is it possible that MSW = 2?
>
> Il dom 3 gen 2021, 23:00 steve freyder <steve@freyder.net 
> <mailto:steve@freyder.net>> ha scritto:
>
>     Each time I would do something like this:
>
>
>     printf(...) ;
>
>     fflush(stdout) ;
>
>     rt_task_sleep(1e9/5) ;
>
>     rt_task_inquire(...) ;
>
>
>     msw incremented by 1, csw would increment by 2.
>
>
>     On 1/3/2021 2:29 PM, Leandro Bucci via Xenomai wrote:
>>     Hi, I have a strange behavior regarding the "mode switch".
>>     In the attached code, the task should never switch to the Linux domain, but
>>     instead I have a value of MSW = 2.
>>     How is it possible?
>>     Even if I do a printf in the task I always get MSW = 2.
>>     I can't understand where the problem is.
>>
>>     #include <stdio.h>
>>     #include <stdlib.h>
>>     #include <unistd.h>
>>     #include <alchemy/task.h>
>>     #include <alchemy/timer.h>
>>
>>     RT_TASK task;
>>     RT_TASK_INFO info;
>>
>>     void task_body(void *arg)
>>     {
>>     rt_task_inquire(NULL, &info);
>>     }
>>
>>     int main()
>>     {
>>     int err;
>>
>>     err = rt_task_create(&task, "mytask", 0, 1, 0);
>>     if (err != 0){
>>     fprintf(stderr, "failed to create task\n");
>>     exit(EXIT_FAILURE);
>>     }
>>
>>     err = rt_task_start(&task, &task_body, NULL);
>>     if (err != 0){
>>     fprintf(stderr, "failed to start task\n");
>>     exit(EXIT_FAILURE);
>>     }
>>
>>     sleep(5); //sleep for 5 seconds
>>
>>     printf("mode switch = %d\n", (int)(info.stat.msw));
>>
>>     exit(EXIT_SUCCESS);
>>     }
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Mode Switch
  2021-01-03 22:00 ` steve freyder
@ 2021-01-03 22:08   ` Leandro Bucci
  2021-01-03 22:16     ` steve freyder
  0 siblings, 1 reply; 12+ messages in thread
From: Leandro Bucci @ 2021-01-03 22:08 UTC (permalink / raw)
  To: steve freyder, xenomai

But in the task I don't do any printf, how is it possible that MSW = 2?

Il dom 3 gen 2021, 23:00 steve freyder <steve@freyder.net> ha scritto:

> Each time I would do something like this:
>
>
> printf(...) ;
>
> fflush(stdout) ;
>
> rt_task_sleep(1e9/5) ;
>
> rt_task_inquire(...) ;
>
>
> msw incremented by 1, csw would increment by 2.
>
>
> On 1/3/2021 2:29 PM, Leandro Bucci via Xenomai wrote:
>
> Hi, I have a strange behavior regarding the "mode switch".
> In the attached code, the task should never switch to the Linux domain, but
> instead I have a value of MSW = 2.
> How is it possible?
> Even if I do a printf in the task I always get MSW = 2.
> I can't understand where the problem is.
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <alchemy/task.h>
> #include <alchemy/timer.h>
>
> RT_TASK task;
> RT_TASK_INFO info;
>
> void task_body(void *arg)
> {
> rt_task_inquire(NULL, &info);
> }
>
> int main()
> {
> int err;
>
> err = rt_task_create(&task, "mytask", 0, 1, 0);
> if (err != 0){
> fprintf(stderr, "failed to create task\n");
> exit(EXIT_FAILURE);
> }
>
> err = rt_task_start(&task, &task_body, NULL);
> if (err != 0){
> fprintf(stderr, "failed to start task\n");
> exit(EXIT_FAILURE);
> }
>
> sleep(5); //sleep for 5 seconds
>
> printf("mode switch = %d\n", (int)(info.stat.msw));
>
> exit(EXIT_SUCCESS);
> }
>
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Mode Switch
  2021-01-03 20:29 Leandro Bucci
@ 2021-01-03 22:00 ` steve freyder
  2021-01-03 22:08   ` Leandro Bucci
  0 siblings, 1 reply; 12+ messages in thread
From: steve freyder @ 2021-01-03 22:00 UTC (permalink / raw)
  To: Leandro Bucci, xenomai

Each time I would do something like this:


printf(...) ;

fflush(stdout) ;

rt_task_sleep(1e9/5) ;

rt_task_inquire(...) ;


msw incremented by 1, csw would increment by 2.


On 1/3/2021 2:29 PM, Leandro Bucci via Xenomai wrote:
> Hi, I have a strange behavior regarding the "mode switch".
> In the attached code, the task should never switch to the Linux domain, but
> instead I have a value of MSW = 2.
> How is it possible?
> Even if I do a printf in the task I always get MSW = 2.
> I can't understand where the problem is.
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <alchemy/task.h>
> #include <alchemy/timer.h>
>
> RT_TASK task;
> RT_TASK_INFO info;
>
> void task_body(void *arg)
> {
> rt_task_inquire(NULL, &info);
> }
>
> int main()
> {
> int err;
>
> err = rt_task_create(&task, "mytask", 0, 1, 0);
> if (err != 0){
> fprintf(stderr, "failed to create task\n");
> exit(EXIT_FAILURE);
> }
>
> err = rt_task_start(&task, &task_body, NULL);
> if (err != 0){
> fprintf(stderr, "failed to start task\n");
> exit(EXIT_FAILURE);
> }
>
> sleep(5); //sleep for 5 seconds
>
> printf("mode switch = %d\n", (int)(info.stat.msw));
>
> exit(EXIT_SUCCESS);
> }

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Mode Switch
@ 2021-01-03 20:29 Leandro Bucci
  2021-01-03 22:00 ` steve freyder
  0 siblings, 1 reply; 12+ messages in thread
From: Leandro Bucci @ 2021-01-03 20:29 UTC (permalink / raw)
  To: xenomai

Hi, I have a strange behavior regarding the "mode switch".
In the attached code, the task should never switch to the Linux domain, but
instead I have a value of MSW = 2.
How is it possible?
Even if I do a printf in the task I always get MSW = 2.
I can't understand where the problem is.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <alchemy/task.h>
#include <alchemy/timer.h>

RT_TASK task;
RT_TASK_INFO info;

void task_body(void *arg)
{
rt_task_inquire(NULL, &info);
}

int main()
{
int err;

err = rt_task_create(&task, "mytask", 0, 1, 0);
if (err != 0){
fprintf(stderr, "failed to create task\n");
exit(EXIT_FAILURE);
}

err = rt_task_start(&task, &task_body, NULL);
if (err != 0){
fprintf(stderr, "failed to start task\n");
exit(EXIT_FAILURE);
}

sleep(5); //sleep for 5 seconds

printf("mode switch = %d\n", (int)(info.stat.msw));

exit(EXIT_SUCCESS);
}

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-02-15 14:06 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-15 13:00 Mode Switch Leandro Bucci
     [not found] ` <358306354.8105980.1613394904650.JavaMail.zimbra@wolfram.com>
2021-02-15 13:16   ` Leandro Bucci
2021-02-15 13:46     ` Per Oberg
2021-02-15 13:52       ` Leandro Bucci
2021-02-15 13:57         ` Julien Blanc
2021-02-15 14:06           ` Leandro Bucci
  -- strict thread matches above, loose matches on Subject: below --
2021-01-03 20:29 Leandro Bucci
2021-01-03 22:00 ` steve freyder
2021-01-03 22:08   ` Leandro Bucci
2021-01-03 22:16     ` steve freyder
2021-01-03 22:22       ` Leandro Bucci
2021-01-03 22:57         ` steve freyder

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.