Giter Site home page Giter Site logo

Comments (6)

peerst avatar peerst commented on June 10, 2024

Just a addendum as is expected by the timer:sleep() test also

receive after 10000 -> timeout end

Takes 20s instead of 10

from grisp-software.

peerst avatar peerst commented on June 10, 2024

Added the folwing code snippet during system startup in the Init task before Erlang is started:

printf("before sleep");
sleep(10);
printf("after sleep");

This sleep takes almost 30s so even more. I get the impression this has nothing to do with our Erlang port but the RTEMS BSP needs to fix the time.

BTW we found out that Erlang uses https://www.freebsd.org/cgi/man.cgi?query=clock_gettime to ask the OS for time mostly. Also the timeouts in the select() call should work precisely since that is used by the Erlang VM whenever it needs to wait for I/O or time passed. Thats just additional info on what to maybe test with didn't check how much these times are off after sleep() already failed.

The configuration we start the system with can be at the end of:

https://github.com/grisp/grisp/blob/master/grisp/grisp_base/sys/erl_main.c

from grisp-software.

c-mauderer avatar c-mauderer commented on June 10, 2024

Hello @peerst,

I had a similar problem on another atsamv based board and I'm currently trying to fix it: A sleep(1) needs a lot longer than 1 second but only if no debugger is connected.

The reason behind it seems to be that the wall clock on the atsamv is implemented based on a counter in the ARM DWT block. This should be a free running counter but it seems that it stops on a WFI (wait for interrupt) instruction. The WFI is used in the idle loop.

Could you try to add the following workaround to your applications configuration:

/* Workarround for problem that the wait instruction in the default idle body
 * has an influence on the cycle counter that is used for the wall clock. */
void *_My_Idle_body(uintptr_t ignored)
{
  for( ; ; ) ;
  return 0;   /* to avoid warning */
}

#define CONFIGURE_IDLE_TASK_BODY _My_Idle_body

If that works, that is the same problem.

Regards

Christian

from grisp-software.

peerst avatar peerst commented on June 10, 2024

Hi @c-mauderer added this snippet and it definitely changed something.

But now a sleep(10) only sleeps 8 Seconds

from grisp-software.

peerst avatar peerst commented on June 10, 2024

Well while sleep() on the C level seems to still behave weirdly the workaround definitely fixes Erlangs notion of time:

(grisp@base0006)5> T1 = erlang:now().     
{567,996917,409432}

wait 100s ...

(grisp@base0006)6> T2 = erlang:now().     
{567,997017,588033}
(grisp@base0006)7> 
(grisp@base0006)9> timer:now_diff(T2, T1)/1000000.
100.178601

from grisp-software.

c-mauderer avatar c-mauderer commented on June 10, 2024

Hello @peerst,

the problem is now fixed in the upstream RTEMS. To keep the impact small for you, I cherry-picked the patch onto the current GRiSP branch of RTEMS. As soon as you update the grisp-software repo to the current master and rebuild RTEMS, you shouldn't need the workarround any more.

Regards

Christian

from grisp-software.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.