Windows 7 Simulator: Learn How to Use Windows 7 in Minutes
The Windows Mixed Reality simulator allows you to test mixed reality apps on your PC without a Windows Mixed Reality immersive headset. The simulator is available with the Windows 10 Creators Update. The simulator is similar to the HoloLens Emulator, though the simulator doesn't use a virtual machine. Simulated apps run in your Windows 10 desktop user session, just like they would if you were using an immersive headset. The human and environmental inputs read by the sensors on an immersive headset are instead simulated using your keyboard, mouse, or Xbox controller. Apps don't need any modification to run in the simulator, and don't know they aren't running on an immersive headset.
windows simulator
You control the simulator by directing the actions of a simulated user wearing an immersive headset. Your actions move the simulated user and cause interactions with apps that respond as they would on an immersive headset.
Preamble - for beginnersIf you are new to FreeRTOS then it is recommended to start by viewing theGetting Started With Simple FreeRTOS Projectsdocumentation (which also describes how to use the FreeRTOS Windows port),before viewing this page.IntroductionThis page presents a Windows port layer for FreeRTOS that has been developed andtested using both Visual Studio Community Editionand the Eclipse IDE for C and C++ Developerswith the MingW GCC based compiler.Demo projects are provided for both tool chains. Both tool chains are also free,although Visual Studio must be registered if it is to be used for anythingother than evaluation purposes.The port was developed on a dual core Intel processor running 32 bit Windows XP,and is now maintained on a quad core Intel processor running 64-bit Windows 10(although the project creates a 32-bit binary).Notes on using the Windows FreeRTOS portPlease read all the following points before using this RTOS port.Principle of Operation
Items to Note Before Using the Port
Source Code Organisation
Using the Eclipse / MingW (GCC) Demo
The Demo Application
Defining and Using Simulated Interrupt Service Routines
Principle of OperationThreads that run tasksThe Windows port layer creates a low priority Windows thread for each FreeRTOS task createdby the FreeRTOS application. All the low priority Windows threads are then keptin the suspended state, other than the Windows thread that is running the FreeRTOStask selected by the FreeRTOS scheduler to be in the Running state. In this way, the FreeRTOSscheduler chooses which low priority Windows thread to run in accordance withits scheduling policy. All the other low priority windows threads cannot run because they are suspended.FreeRTOS ports that run on microcontrollers have to perform complex contextswitching to save and restore the microcontroller context (registers, etc.) astasks enter and leave the Running state. In contrast, the Windows simulatorlayer simply has to suspend and resume Windows threads as the tasks they represententer and leave the Running state. The real context switching is left to Windows.Simulating the tick interruptThe tick interrupt generation is simulated by a high priority Windows thread that willperiodically pre-empt the low priority threads that are running tasks. The tickrate achievable is limited by the Windows system clock, which in normal FreeRTOSterms is slow and has a very low precision. It is therefore not possible toobtain true real time behaviour.Simulating interrupt processingSimulated interrupt processing is performed by a second higher priority Windowsthread that, because of its priority, can also pre-empt the low priority threadsthat are running FreeRTOS tasks. The thread that simulates interrupt processingwaits until it is informed by another thread in the system that there is aninterrupt pending. For example the thread that simulates the generation of tickinterrupts sets an interrupt pending bit, and then informs the Windows threadthat simulates interrupts being processed that an interrupt is pending. The simulatedinterrupt processing thread will then execute and look at all the possible interrupt pending bits- performing any simulated interrupt processing and clearing interrupt pending bits as necessary.Items to Note Before Using the SimulatorWindows programming by embedded engineersBefore using the provided Windows projects, please be aware that I (the authourof the Windows simulator) am an embedded programmer, am not a Windows programmer.The implementation may be naive. Any feedbackprovided on the current implementation by those more knowledgeable about Windowsprogramming would be gratefully received.Deleting tasks on WindowsWhen a FreeRTOS task is deleted, the Windows port will terminate the thread thatwas responsible for running the task. However, under Windows, terminating athread from another thread will not cause theresources that were being used by the terminated thread to be returned to the system. Thismeans that at run time there is a limit to the number of times the FreeRTOSvTaskDelete() API function can be called. The limit is very high (many thousands),but does prevent the standard demo 'death'tasks from executing indefinitely before the demo tasks start toreport errors.Load on the CPU of the host Windows machineThe load on the CPU of the host Windows machine will be very high while aFreeRTOS application is being run. Responsiveness should not be toobadly effected because only low priority threads are used, but the CPU core temperaturewill rise and the CPU cooling fans will respond accordingly.If you are in any way concerned about the ability of yourcomputer to cope with the high temperatures generated then I would suggest theuse of a utility that provides information on both the current CPU core temperature,and how close the current temperature is to the maximum temperature rating of yourparticular CPU. Personally I use the freeCore Temputility for this purpose.Source Code OrganisationEclipse and MingW (GCC)The Eclipse project for the FreeRTOS simulator demo applicationis located in the FreeRTOS/Demo/WIN32-MingW directory of the mainFreeRTOS download. This needs to be imported into the Eclipse workspace in orderto build the project.Visual StudioThe Visual Studio solution for the FreeRTOS simulator demo applicationis called WIN32.sln and is located in the FreeRTOS/Demo/WIN32-MSVNdirectory of the main FreeRTOS download.Using the Eclipse and MingW (GCC) DemoObtaining the compilerThe MingW compilation toolsare not included as part of the Eclipse distribution and must be downloadedseparately.Importing the FreeRTOS simulator project into an Eclipse workspaceTo import the FreeRTOS simulator project into Eclipse:Start the Eclipse IDE, and go to the Eclipse Workbench.
Select 'Import' from the Eclipse 'File' menu. A dialogue box willappear.
In the dialogue box, select 'General Existing Projects Into Workspace'.Another dialogue box will appear that allows you to navigate to andselect a root directory.
Select FreeRTOS/Demo/WIN32-MingWas the directory - this will reveal a project called RTOSDemo, which is the projectthat should be imported.
The Demo ApplicationFunctionalityThe constant mainCREATE_SIMPLE_BLINKY_DEMO_ONLY, which is #defined at the top of main.c, is used to switch between a simply Blinky style demo, and a more comprehensive test and demo application, as described in the next two sections.Functionality when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1If mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1 then main() will callmain_blinky(), which is implemented in main_blinky.c.main_blinky() creates a very simple demo that includes two tasks and one queue.One task repeatedly sends the value 100 to the other task through the queue. Thereceiving task prints out a message each time it receives the value on the queue.Functionality when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0If mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0 then main() will callmain_full(), which is implemented in main_full.c.The demo created by main_full() is very comprehensive. The tasks it createsconsist mainly of the standard demo tasks - whichdon't perform any particular functionality other than testing the portand demonstrating how the FreeRTOS API can be used.The 'check' task created by main_full()The full demo creates a 'check' task in addition to the standard demo tasks. Thisonly executes every (simulated) five seconds, but has the highest priority toensure it gets processing time. Its main function is to check that all thestandard demo tasks are still operational.The check task maintains a status string that is output to the console each timeit executes. If all the standard demo tasks are running without error then thestring will print out "OK" and the current tick count. If an error has been detectedthen the string will print out a message that indicates in which task the errorwas reported.Viewing the console outputThe eclipse project will output strings to an integrated console. To view thesestrings the "RTOSDemo.exe" console must be selected using the drop down listaccessible from the little computer monitor icon speed button - as shown in theimage below.The Visual Studio console output will appear in a command prompt window.Selecting the "RTOSDemo.exe" console during an Eclipse debug sessionDefining and Using Simulated Interrupt Service RoutinesDefining a handler for a simulated interrupt service routineInterrupt service routines must have the following prototype:unsigned long ulInterruptName( void );where 'ulInterruptName' can be any appropriate function name.If executing the routine should result in a context switch then the interruptfunction must return pdTRUE. Otherwise the interrupt function should returnpdFALSE.Installing a handler for a simulated interrupt service routineHandlers for simulated interrupt service routines can be installed using thevPortSetInterruptHandler() function which is defined in the Win32port layer. This has the prototype shown below:void vPortSetInterruptHandler( unsigned long ulInterruptNumber, unsigned long (*pvHandler)( void ) );ulInterruptNumber must be a value in the range 3 to 31 inclusive and beunique within the application (meaning a total of 29 simulated interruptscan be defined in any application). Numbers0 to 2 inclusive are used by the simulator itself.pvHandler should point to the handler function for the interrupt numberbeing installed.Triggering a simulated interrupt service routineInterrupts can be set pending and, if appropriate, executed by calling thevPortGenerateSimulatedInterrupt() function, which is also defined as partof the Win32 port layer. It has the prototype shown below:void vPortGenerateSimulatedInterrupt( unsigned long ulInterruptNumber );ulInterruptNumber is the number of the interrupt that is to be set pending, andcorresponds to the ulInterruptNumber parameter of vPortSetInterruptHandler().An example of installing and triggering an interruptThe simulator itself uses three interrupts, one for a task yield, one for thesimulated tick, and one for terminating a Windows thread that was executing a FreeRTOStask that has since been deleted. As a simple example, shown below is the codefor the yield interrupt.The interrupt function does nothing other than request a context switch, sojust returns pdTRUE. It is defined using the following code:static unsigned long prvProcessYieldInterrupt( void ) /* There is no processing to do here, this interrupt is just used to cause a context switch, so it simply returns pdTRUE. */ return pdTRUE;The simulated interrupt handler function is then installed using the following call,where portINTERRUPT_YIELD is defined as 2:vPortSetInterruptHandler( portINTERRUPT_YIELD, prvProcessYieldInterrupt );This is the interrupt that should execute whenever taskYIELD()/portYIELD() iscalled, so the Win32 port version of portYIELD() is defined as:#define portYIELD()vPortGenerateSimulatedInterrupt( portINTERRUPT_YIELD )