This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

multiple instances of ITC objects in CMSIS-RTOS

Hello,

I'd like to write some reusabel code module to handle e.g. UART ports. Therefore I'd like to create a variable number (based on some kind of define...) of threads dealing with UART port 1,2,3 ... since it is possible to declare CMSIS-RTOS threads with a variable number of instances it could look like this:

#define UART_PORT_NUM 3

osThreadDef(uart_thread, osPriorityNormal, UART_PORT_NUM, 0)

my problem: If I need any kind of inter-thread communication (ITC) object, like mutexes or mail queues, for each of this threads I don't know how to declare them, since osMailQDef, osMutexDef and so on, are not designed with a "variable" number of instances...

Any suggestions?

Parents
  • Since your code would normally need very explicit knowledge about what to do with data from each UART, I can't see why it would be an advantage to try to create n identical threds.

    Why not make four calls to instantiate the four threads? In a real situation, it would be likely that you would want different priority for different UART.

    Is it really identical data you want to process from all your UART? Because if it was, then it would be likely that you would be expected to use the same mail queues for forwarding your received and processed data. And if the four UART produces identical data, then it would be likely that you would only need one single thread to pick up data and process - while you have four ISR that reacts to the hardware and posts the received data to that single queue.

Reply
  • Since your code would normally need very explicit knowledge about what to do with data from each UART, I can't see why it would be an advantage to try to create n identical threds.

    Why not make four calls to instantiate the four threads? In a real situation, it would be likely that you would want different priority for different UART.

    Is it really identical data you want to process from all your UART? Because if it was, then it would be likely that you would be expected to use the same mail queues for forwarding your received and processed data. And if the four UART produces identical data, then it would be likely that you would only need one single thread to pick up data and process - while you have four ISR that reacts to the hardware and posts the received data to that single queue.

Children