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




Loading

Starting 'N' Tasks with a counting sem...

Posted by steveb on November 25, 2010
Hello All.

(Using PIC32 Starter Kit)

I'm trying to implement a sync/task start mechanism using counting semaphores. The purpose is to
ensure all task Q's/Semaphores and H/W is configured before any task begins communicating with
another task.

I have 5 tasks, each creating a Q or semaphore and corresponding H/W configuration. Each task calls
semGive on a counting (taskReady) semaphore then immediately blocks on another counting (taskStart)
semaphore.
I have a 6th 'supervisor' task that blocks on the taskReady semaphore and loops (semTake) around this
semaphore until all tasks have reported ready. Once all tasks have given the taskReady semaphore, the
'supervisor' task then gives the taskStart semaphore 5 times to allow each task to continue.

The problem I'm facing is only the following two tasks that are created after the supervisor task (from within main())
ever start i.e. supervisor is created 1st followed by task A, task B etc.... These tasks, A and B call semGive(taskReady) and the supervisor task unblocks twice (semTake(taskReady). A breakpoint in the third created task (or any of the other tasks) never hits?

My understanding is that each task should start in accordance with the scheduler rules i.e based on the task pri or maybe the task creation order. After the supervisor task is unblocked twice for task A/B's semGive(taskReady), it becomes blocked again (permantently). I would expect one of the other tasks to run and call its semGive(taskReady)?

Any suggestions/advice would be greatly appreciated.

Regards,
Steve

RE: Starting 'N' Tasks with a counting sem...

Posted by Dave on November 25, 2010
It sounds like a very complex scheme and suspect the problem lies in its complexity somewhere.

Why not initialize the hardware before starting the scheduler? If you want to modularize the drivers you can still have the driver encapsulate an initialization function that is called before the task is started.

Alternatively you could have the tasks suspend themselves when they are ready and then the main task can simply check that all the tasks are suspended before starting the real work.

RE: Starting 'N' Tasks with a counting sem...

Posted by Richard Damon on November 25, 2010
One though, have you checked that the tasks were successfully created? If you run out of heap, then the tasks won't all be created.

RE: Starting 'N' Tasks with a counting sem...

Posted by steveb on November 25, 2010
Thx chaps for the prompt feedback!

It seems I should not have been lazy and checked if each task was created correctly. Turns out more memory is required. Good call Richard.

Dave - thx for your suggestion as well.

Cheers,
Steve


[ 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