kopia lustrzana https://github.com/OpenRTX/OpenRTX
Added macros for thread priority levels
rodzic
ae0a467d2a
commit
565a056e82
|
@ -1,5 +1,5 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2020 - 2023 by Federico Amedeo Izzo IU2NUO, *
|
||||
* Copyright (C) 2020 - 2024 by Federico Amedeo Izzo IU2NUO, *
|
||||
* Niccolò Izzo IU2KIN *
|
||||
* Frederik Saraci IU2NRO *
|
||||
* Silvano Seva IU2KWO *
|
||||
|
@ -23,29 +23,26 @@
|
|||
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* Threads' stack sizes
|
||||
*/
|
||||
#define UI_THREAD_STKSIZE 2048
|
||||
#define RTX_THREAD_STKSIZE 512
|
||||
#define CODEC2_THREAD_STKSIZE 16384
|
||||
|
||||
/**
|
||||
* Thread priority levels, UNIX-like: lower level, higher thread priority
|
||||
*/
|
||||
#ifdef _MIOSIX
|
||||
#define THREAD_PRIO_RT 0
|
||||
#define THREAD_PRIO_HIGH 1
|
||||
#define THREAD_PRIO_NORMAL 2
|
||||
#define THREAD_PRIO_LOW 3
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Spawn all the threads for the various functionalities.
|
||||
*/
|
||||
void create_threads();
|
||||
|
||||
/**
|
||||
* Stack size for state update task, in bytes.
|
||||
*/
|
||||
#define DEV_TASK_STKSIZE 2048
|
||||
|
||||
/**
|
||||
* Stack size for UI management, in bytes.
|
||||
*/
|
||||
#define UI_TASK_STKSIZE 2048
|
||||
|
||||
/**
|
||||
* Stack size for baseband control task, in bytes.
|
||||
*/
|
||||
#define RTX_TASK_STKSIZE 512
|
||||
|
||||
/**
|
||||
* Stack size for codec2 task, in bytes.
|
||||
*/
|
||||
#define CODEC2_TASK_STKSIZE 16384
|
||||
|
||||
#endif /* THREADS_H */
|
||||
|
|
|
@ -400,16 +400,16 @@ static bool startThread(const pathId path, void *(*func) (void *))
|
|||
|
||||
#if defined(_MIOSIX)
|
||||
// Set stack size of CODEC2 thread to 16kB.
|
||||
pthread_attr_setstacksize(&codecAttr, CODEC2_TASK_STKSIZE);
|
||||
pthread_attr_setstacksize(&codecAttr, CODEC2_THREAD_STKSIZE);
|
||||
|
||||
// Set priority of CODEC2 thread to the maximum one, the same of RTX thread.
|
||||
struct sched_param param;
|
||||
param.sched_priority = sched_get_priority_max(0);
|
||||
param.sched_priority = THREAD_PRIO_HIGH;
|
||||
pthread_attr_setschedparam(&codecAttr, ¶m);
|
||||
#elif defined(__ZEPHYR__)
|
||||
// Allocate and set the stack for CODEC2 thread
|
||||
void *codec_thread_stack = malloc(CODEC2_TASK_STKSIZE * sizeof(uint8_t));
|
||||
pthread_attr_setstack(&codecAttr, codec_thread_stack, CODEC2_TASK_STKSIZE);
|
||||
void *codec_thread_stack = malloc(CODEC2_THREAD_STKSIZE * sizeof(uint8_t));
|
||||
pthread_attr_setstack(&codecAttr, codec_thread_stack, CODEC2_THREAD_STKSIZE);
|
||||
#endif
|
||||
|
||||
// Start thread
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2020 - 2023 by Federico Amedeo Izzo IU2NUO, *
|
||||
* Copyright (C) 2020 - 2024 by Federico Amedeo Izzo IU2NUO, *
|
||||
* Niccolò Izzo IU2KIN *
|
||||
* Frederik Saraci IU2NRO *
|
||||
* Silvano Seva IU2KWO *
|
||||
|
@ -205,16 +205,16 @@ void create_threads()
|
|||
pthread_attr_init(&rtx_attr);
|
||||
|
||||
#ifndef __ZEPHYR__
|
||||
pthread_attr_setstacksize(&rtx_attr, RTX_TASK_STKSIZE);
|
||||
pthread_attr_setstacksize(&rtx_attr, RTX_THREAD_STKSIZE);
|
||||
#else
|
||||
void *rtx_thread_stack = malloc(RTX_TASK_STKSIZE * sizeof(uint8_t));
|
||||
pthread_attr_setstack(&rtx_attr, rtx_thread_stack, RTX_TASK_STKSIZE);
|
||||
void *rtx_thread_stack = malloc(RTX_THREAD_STKSIZE * sizeof(uint8_t));
|
||||
pthread_attr_setstack(&rtx_attr, rtx_thread_stack, RTX_THREAD_STKSIZE);
|
||||
#endif
|
||||
|
||||
#ifdef _MIOSIX
|
||||
// Max priority for RTX thread when running with miosix rtos
|
||||
struct sched_param param;
|
||||
param.sched_priority = sched_get_priority_max(0);
|
||||
param.sched_priority = THREAD_PRIO_HIGH;
|
||||
pthread_attr_setschedparam(&rtx_attr, ¶m);
|
||||
#endif
|
||||
|
||||
|
@ -226,10 +226,10 @@ void create_threads()
|
|||
pthread_attr_init(&ui_attr);
|
||||
|
||||
#ifndef __ZEPHYR__
|
||||
pthread_attr_setstacksize(&ui_attr, UI_TASK_STKSIZE);
|
||||
pthread_attr_setstacksize(&ui_attr, UI_THREAD_STKSIZE);
|
||||
#else
|
||||
void *ui_thread_stack = malloc(UI_TASK_STKSIZE * sizeof(uint8_t));
|
||||
pthread_attr_setstack(&ui_attr, ui_thread_stack, UI_TASK_STKSIZE);
|
||||
void *ui_thread_stack = malloc(UI_THREAD_STKSIZE * sizeof(uint8_t));
|
||||
pthread_attr_setstack(&ui_attr, ui_thread_stack, UI_THREAD_STKSIZE);
|
||||
#endif
|
||||
|
||||
pthread_t ui_thread;
|
||||
|
|
Ładowanie…
Reference in New Issue