Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ctrl-c don't stop hardware timer #287

Open
Mynogs opened this issue Jul 22, 2019 · 10 comments
Open

ctrl-c don't stop hardware timer #287

Mynogs opened this issue Jul 22, 2019 · 10 comments

Comments

@Mynogs
Copy link
Contributor

Mynogs commented Jul 22, 2019

I have this main simulation loop with cyclic hardware based timer.
I use putty to connect to the esp. I press ctrl-c to stop my application.
The Lua prompt is now visible. With the next return the board hooks up completly.
If I use software timer everthing works fine.
startup.lua.txt

@Mynogs
Copy link
Contributor Author

Mynogs commented Jul 24, 2019

I change my system to use threads.
If I use hardware timers inside the thread and stop these thread with thread.stop then it looks the hardware timers are still in use. With the next return on the shell the board hooks up completly.
Only when I call collectgarbage('collect') are the timers released.
So the workaround looks like thread.stop(simulation);collectgarbage('collect').

@jolivepetrus
Copy link
Contributor

@Mynogs,

Well, we really can't do any assumption on what to do with the hardware resources used by a thread when it is stopped.

I think that one solution is to modify the Lua thread API to allow some type of callback when the thread is going to be stopped and write specific code to handle that situation.

@Mynogs
Copy link
Contributor Author

Mynogs commented Jul 25, 2019

@jolivepetrus

I think a callback function for a good solution. In most cases, the garbage collector will be able to release the orphan objects. Only he is just too late now. So in most cases it will suffice to call collectgarbage ('collect') in the callback function

@the0ne
Copy link
Collaborator

the0ne commented Jul 25, 2019

That sounds like calling the GC would be a good idea whenever a thread is stopped.
Any objections to that proposal? Of cause the callback is still a good idea - additionally.

@Mynogs
Copy link
Contributor Author

Mynogs commented Jul 25, 2019

@the0ne
Always calling the GC can have side effects. At least in timing behave.

@Mynogs
Copy link
Contributor Author

Mynogs commented Jul 25, 2019

Another possibility would be the exception handling. ctrl-c and thread stop would trigger an exeption. But only if it occurs within a try. This would suppress an error message if there is no try.

@Mynogs
Copy link
Contributor Author

Mynogs commented Aug 8, 2019

How do we continue here?

@the0ne
Copy link
Collaborator

the0ne commented Aug 8, 2019

@the0ne
Always calling the GC can have side effects. At least in timing behave.

I don't think that there's a timing defined currently for the process of stopping a thread.

@the0ne
Copy link
Collaborator

the0ne commented Aug 8, 2019

How do we continue here?

Next step is to create a patch, test it and submit it as a PR.
Anybody who has some spare time can do that :-)

@Mynogs
Copy link
Contributor Author

Mynogs commented Aug 23, 2019

@the0ne
Of course you are right!
We use the ESP32 with the Lua-RTOS for commercial projects. My colleague is just beginning to setup the development enviroment so that we can participate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants