FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [January 2016 Threads] Can I run more than one instance of a thread?Posted by dibosco on January 13, 2016 Is it possible to create a generic thread that you create multiple times, but with a different passed parameter and have those tasks run independently?
Specificially I have a thread that opens a file on an SD card, reads info off the file in small chunks and sends it to another thread to process. I'd really like to be able to create that thread up to six times, each time passing the path to file on the SD card to open as the thread's parameter, then that thread pass values back to another thread via a queue. So, I could have a few files open at the same time with each instance of the SD card reading thread passing information via the [same] queue.
Once I'd finished with it, I'd then destroy the thread.
Is that possible/sensible/stupid?
Thanks!
Rob
Can I run more than one instance of a thread?Posted by rtel on January 13, 2016 Yes, definitely possible, but watch out for thread safety issues when accessing the SD card. Are you using our FAT file system? If so, I think the Windows demo does just that.
As a very simple example, you could look at the LED flash standard demo (although the file is very old!). There is only one task implemented, but many instances of the task. This works because each task has its own context - its own stack and its own [virtua] set of CPU register.
Can I run more than one instance of a thread?Posted by dibosco on January 13, 2016 I'm using the Chan FS, I didn't even know you had one as well!
I used a mutex to ensure only one thread was accessing the libraries at any time and ensure safety and it seems to be working nicely. :)
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|