Hi,
analyzing the code to simulate ChibiOS under Win32, I found that the biggest difference between embedded execution and simulated execution is the way it makes the context switch (CS).
In embedded execution CS is driven by an interrupt, instead in simulated execution CS is done into Idle thread.
In order to simulate better the embedded execution, I've thought about a timer in a windows thread connected to a callback function, called every 10 ms.
I use this callback function to generate the system tick, CS, and to process serial messages from console. It's simply an interrupt simulation.
The system runs good, but when I try to do the command "test", at the point 3.2 it freezes... 50% of CPU is used (I've got a 4 processor pc)... and never returns!
With some debug technique I found that my interrupt simulation thread freezes! I think that there's a loop in the test that blocks all other threads in the program.
Calling regularly the function ChkIntSources() (I've commented it to do my tests ), the 3.2 point fails, but does not stall!!!!
The interrupt simulation is based on a windows thread and a windows timer. I report here the API functions used:
CreateWaitableTimer
SetWaitableTimer
SleepEx
CreateThread
SetThreadPriority
ResumeThread
In my opinion the program stalls because the timer thread is part of the same program process. But I don't know how to resolve this problem.
Does anyone have an idea on how to solve this?
Thank you very much,
Alessandro
WIN32 Simulator Improvement
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: WIN32 Simulator Improvement
It is not working because you are switching the thread registers not the registers of the simulator.
Giovanni
Giovanni
-
- Posts: 7
- Joined: Fri Jul 08, 2011 3:25 pm
Re: WIN32 Simulator Improvement
And so, as far as you know, is there a way to switch all the registers of the simulator under win32?
Thanks, Regards.
Alessandro
Thanks, Regards.
Alessandro
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: WIN32 Simulator Improvement
Win32 does not have any mechanism to asynchronously interrupt the execution of a process as far I know, the Linux/Posix simulator could use signal APIs in that role.
ciao,
Giovanni
ciao,
Giovanni
Return to “Development and Feedback”
Who is online
Users browsing this forum: Baidu [Spider] and 75 guests