I am getting ADC data from three ADC channels and doing some processing in the ADC callback. When my data buffer is ready, I switch buffers and need to send the full buffers to another thread for processing while the second set of buffers fill.
I have not been able to figure out how to start a thread with parameters.
Anybody got any ideas?
Thanks
-John Scott
starting thread with parameters...
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: starting thread with parameters...
Hi,
The last parameter of thread create functions is a parameter that is passed to the created thread, if you need more than a parameter then you may use it to pass a pointer to a structure.
Giovanni
The last parameter of thread create functions is a parameter that is passed to the created thread, if you need more than a parameter then you may use it to pass a pointer to a structure.
Giovanni
Re: starting thread with parameters...
Also, do you really want to start the other thread or just send it a message when the ADC conv is done? It it's happening constantly it would maybe make more sense to have the processing thread wait and receive via a mailbox or some other synchronization construct.
Re: starting thread with parameters...
Colin,
Yea, I think just passing a message might be better.
That would solve the problem I have with defining
a thread in one module and creating the thread.
Giovanni,
How would I go about having one module named processing.c that contains a thread defined in the usual way. Then call the create process function from another module, for example main.c?
Normally I would just create prototypes in a header file, but don't know how to deal with the process working area.
In the past, I have just called a stub in the module with the thread, then started the thread locally.
-john Scott
Yea, I think just passing a message might be better.
That would solve the problem I have with defining
a thread in one module and creating the thread.
Giovanni,
How would I go about having one module named processing.c that contains a thread defined in the usual way. Then call the create process function from another module, for example main.c?
Normally I would just create prototypes in a header file, but don't know how to deal with the process working area.
In the past, I have just called a stub in the module with the thread, then started the thread locally.
-john Scott
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: starting thread with parameters...
Creating a separate module for the thread is a clean approach, no problems with that. In the header file put the thread function prototype and the re-declaration of the working area preceded by "extern".
The result, depending on the port, is something like:
extern stkalign_t myWA[1024];
Giovanni
The result, depending on the port, is something like:
extern stkalign_t myWA[1024];
Giovanni