Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


windows freeRTOS simulator: integrating windows thread and freertos task

Posted by gavril on April 1, 2015

I want to connect Windows threads which are not under my control with the tasks of the Windows freeRTOS simulator. These threads are part of the drivers that control the PC hardware.

One thread related to the audio system of the PC and calls user-define callback function (or event) each time the audio buffer needs to be reloaded (waveOutProc callback, see https://msdn.microsoft.com/en-us/library/dd743869%28v=vs.85%29.aspx). The goal of this project is to develop Windows based emulator of a freeRTOS based firmware project (ARM Cortex) where hardware of the embedded system are replaced by hardware/drivers resources of the PC.

I tried several ways of integrating this audio callback function/thread with the freeRTOS tasks but I did not find a working solution.

1) I have first tried to use semaphore in the audio callback (xSemaphoreGive) to wake up a freeRTOS task that would compute and fill-up the audio buffer. It did not work and the reason could be that it windows mutex in the waveOutProc callback function. Only a few limited system function calls are allowed but Windows feeRTOS semaphore implementation use mutexes. This is also true for the simulated interrupts (vPortGenerateSimulatedInterrupt).

2) A possibility would be to use Windows setEvent function in the audio callback (which is allowed) and to insert of Windows WaitForSingleObject in the freeRTOS task to block it until the event. This would replace the freeRTOS semaphore but I think that it will wreack havoc with the freeRTOS schedular since the task would be blocked by a primitive that is not managed by the scheduler.

windows freeRTOS simulator: integrating windows thread and freertos task

Posted by rtel on April 1, 2015

We have found it very difficult, if not impossible, to mix Windows system calls with FreeRTOS task. Sometimes it can appear to work for a long time, but under heavy load, eventually the windows system calls with interfere with the working of the FreeRTOS scheduler.

I think we experienced a similar issue when creating some of the FreeRTOS+TCP demos - especially in the driver. To get around the issue there we used a thread safe circular buffer to pass data between Windows threads and FreeRTOS tasks - that didn't use any system calls but there was no easy way of signalling the destination thread/task that new data was available so we then had to introduce a 'polling' task the keep looking at the circular buffer to see if it contained new data. Not very elegant, but reliable. In the following link, which is otherwise unreleated, you will find some info on the "stream buffer" used for this purpose. Its implementation is in a source file in the FreeRTOS+TCP code.



[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists