removed low prio queue

sipo
Ondřej Hruška 7 years ago
parent 97b6fd0028
commit 4f92b97305
  1. 39
      freertos.c
  2. 3
      tasks/sched_queue.h
  3. 43
      tasks/task_sched.c
  4. 17
      tasks/task_sched.h
  5. 8
      utils/stacksmon.c

@ -60,8 +60,7 @@
#define STACK_MAIN 160 #define STACK_MAIN 160
#define STACK_MSG 230 #define STACK_MSG 230
#define STACK_LP 180 #define STACK_JOBRUNNER 150
#define STACK_HP 150
osThreadId tskMainHandle; osThreadId tskMainHandle;
uint32_t mainTaskBuffer[ STACK_MAIN ]; uint32_t mainTaskBuffer[ STACK_MAIN ];
@ -71,19 +70,11 @@ osThreadId tskMsgHandle;
uint32_t msgTaskBuffer[ STACK_MSG ]; uint32_t msgTaskBuffer[ STACK_MSG ];
osStaticThreadDef_t msgTaskControlBlock; osStaticThreadDef_t msgTaskControlBlock;
osThreadId tskSchedLPHandle; osThreadId tskJobRunnerHandle;
uint32_t schedLowBuffer[ STACK_LP ]; uint32_t jobRunnerBuffer[ STACK_JOBRUNNER ];
osStaticThreadDef_t schedLowControlBlock; osStaticThreadDef_t jobRunnerControlBlock;
osThreadId tskSchedHPHandle; osMessageQId queSchedHandle;
uint32_t schedHighBuffer[ STACK_HP ];
osStaticThreadDef_t schedHighControlBlock;
osMessageQId queSchedLPHandle;
uint8_t myQueue01Buffer[ LP_SCHED_CAPACITY * sizeof( struct sched_que_item ) ];
osStaticMessageQDef_t myQueue01ControlBlock;
osMessageQId queSchedHPHandle;
uint8_t myQueue02Buffer[ HP_SCHED_CAPACITY * sizeof( struct sched_que_item ) ]; uint8_t myQueue02Buffer[ HP_SCHED_CAPACITY * sizeof( struct sched_que_item ) ];
osStaticMessageQDef_t myQueue02ControlBlock; osStaticMessageQDef_t myQueue02ControlBlock;
@ -104,7 +95,7 @@ osStaticSemaphoreDef_t myBinarySem01ControlBlock;
/* Function prototypes -------------------------------------------------------*/ /* Function prototypes -------------------------------------------------------*/
void TaskMain(void const * argument); void TaskMain(void const * argument);
extern void TaskSchedLP(void const * argument); extern void TaskSchedLP(void const * argument);
extern void TaskSchedHP(void const * argument); extern void TaskJobQueue(void const *argument);
extern void TaskMessaging(void const * argument); extern void TaskMessaging(void const * argument);
void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */ void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
@ -146,8 +137,7 @@ void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackTy
void MX_FREERTOS_Init(void) { void MX_FREERTOS_Init(void) {
/* USER CODE BEGIN Init */ /* USER CODE BEGIN Init */
stackmon_register("Main", mainTaskBuffer, sizeof(mainTaskBuffer)); stackmon_register("Main", mainTaskBuffer, sizeof(mainTaskBuffer));
stackmon_register("Job Queue Low", schedLowBuffer, sizeof(schedLowBuffer)); stackmon_register("JobRunner", jobRunnerBuffer, sizeof(jobRunnerBuffer));
stackmon_register("Job Queue High", schedHighBuffer, sizeof(schedHighBuffer));
stackmon_register("Messaging", msgTaskBuffer, sizeof(msgTaskBuffer)); stackmon_register("Messaging", msgTaskBuffer, sizeof(msgTaskBuffer));
/* USER CODE END Init */ /* USER CODE END Init */
@ -179,13 +169,9 @@ void MX_FREERTOS_Init(void) {
osThreadStaticDef(tskMain, TaskMain, osPriorityHigh, 0, STACK_MAIN, mainTaskBuffer, &mainTaskControlBlock); osThreadStaticDef(tskMain, TaskMain, osPriorityHigh, 0, STACK_MAIN, mainTaskBuffer, &mainTaskControlBlock);
tskMainHandle = osThreadCreate(osThread(tskMain), NULL); tskMainHandle = osThreadCreate(osThread(tskMain), NULL);
/* definition and creation of tskSchedLP */ /* definition and creation of tskJobRunner */
osThreadStaticDef(tskSchedLP, TaskSchedLP, osPriorityLow, 0, STACK_LP, schedLowBuffer, &schedLowControlBlock); osThreadStaticDef(tskJobRunner, TaskJobQueue, osPriorityAboveNormal, 0, STACK_JOBRUNNER, jobRunnerBuffer, &jobRunnerControlBlock);
tskSchedLPHandle = osThreadCreate(osThread(tskSchedLP), NULL); tskJobRunnerHandle = osThreadCreate(osThread(tskJobRunner), NULL);
/* definition and creation of tskSchedHP */
osThreadStaticDef(tskSchedHP, TaskSchedHP, osPriorityAboveNormal, 0, STACK_HP, schedHighBuffer, &schedHighControlBlock);
tskSchedHPHandle = osThreadCreate(osThread(tskSchedHP), NULL);
/* definition and creation of TaskMessaging */ /* definition and creation of TaskMessaging */
osThreadStaticDef(tskMsg, TaskMessaging, osPriorityNormal, 0, STACK_MSG, msgTaskBuffer, &msgTaskControlBlock); osThreadStaticDef(tskMsg, TaskMessaging, osPriorityNormal, 0, STACK_MSG, msgTaskBuffer, &msgTaskControlBlock);
@ -196,13 +182,10 @@ void MX_FREERTOS_Init(void) {
/* USER CODE END RTOS_THREADS */ /* USER CODE END RTOS_THREADS */
/* Create the queue(s) */ /* Create the queue(s) */
/* definition and creation of queSchedLP */
osMessageQStaticDef(queSchedLP, LP_SCHED_CAPACITY, struct sched_que_item, myQueue01Buffer, &myQueue01ControlBlock);
queSchedLPHandle = osMessageCreate(osMessageQ(queSchedLP), NULL);
/* definition and creation of queSchedHP */ /* definition and creation of queSchedHP */
osMessageQStaticDef(queSchedHP, HP_SCHED_CAPACITY, struct sched_que_item, myQueue02Buffer, &myQueue02ControlBlock); osMessageQStaticDef(queSchedHP, HP_SCHED_CAPACITY, struct sched_que_item, myQueue02Buffer, &myQueue02ControlBlock);
queSchedHPHandle = osMessageCreate(osMessageQ(queSchedHP), NULL); queSchedHandle = osMessageCreate(osMessageQ(queSchedHP), NULL);
/* definition and creation of queRxData */ /* definition and creation of queRxData */
osMessageQStaticDef(queRxData, RX_QUE_CAPACITY, struct rx_que_item, myQueue03Buffer, &myQueue03ControlBlock); osMessageQStaticDef(queRxData, RX_QUE_CAPACITY, struct rx_que_item, myQueue03Buffer, &myQueue03ControlBlock);

@ -5,7 +5,7 @@
#ifndef GEX_SCHED_QUEUE_H #ifndef GEX_SCHED_QUEUE_H
#define GEX_SCHED_QUEUE_H #define GEX_SCHED_QUEUE_H
#include <TinyFrame/TinyFrame.h> #include <TinyFrame.h>
typedef struct sched_que_item Job; typedef struct sched_que_item Job;
typedef void (*ScheduledJobCb) (Job *job); typedef void (*ScheduledJobCb) (Job *job);
@ -35,7 +35,6 @@ struct rx_que_item {
uint8_t data[64]; uint8_t data[64];
}; };
#define LP_SCHED_CAPACITY 5
#define HP_SCHED_CAPACITY 5 #define HP_SCHED_CAPACITY 5
#define RX_QUE_CAPACITY 16 #define RX_QUE_CAPACITY 16

@ -5,23 +5,18 @@
#include "platform.h" #include "platform.h"
#include "task_sched.h" #include "task_sched.h"
extern osMessageQId queSchedLPHandle; extern osMessageQId queSchedHandle;
extern osMessageQId queSchedHPHandle;
volatile uint32_t jobQueHighWaterMarkHP = 0; volatile uint32_t jobQueHighWaterMark = 0;
volatile uint32_t jobQueHighWaterMarkLP = 0;
/** /**
* Schedule a function for later execution in the jobs thread * Schedule a function for later execution in the jobs thread
* *
* @param callback - the callback function * @param callback - the callback function
* @param prio - priority, selects which job queue to use
* @param data1 - first data object, NULL if not needed; usually context/handle
* @param data2 - second data object, NULL if not needed; usually data/argument
*/ */
void scheduleJob(Job *job, enum task_sched_prio prio) void scheduleJob(Job *job)
{ {
QueueHandle_t que = (prio == TSK_SCHED_LOW ? queSchedLPHandle : queSchedHPHandle); QueueHandle_t que = queSchedHandle;
assert_param(que != NULL); assert_param(que != NULL);
assert_param(job->cb != NULL); assert_param(job->cb != NULL);
@ -44,44 +39,22 @@ void scheduleJob(Job *job, enum task_sched_prio prio)
} }
#if USE_STACK_MONITOR #if USE_STACK_MONITOR
if (prio == TSK_SCHED_LOW) { jobQueHighWaterMark = MAX(jobQueHighWaterMark, count);
jobQueHighWaterMarkLP = MAX(jobQueHighWaterMarkLP, count);
} else {
jobQueHighWaterMarkHP = MAX(jobQueHighWaterMarkHP, count);
}
#endif #endif
} }
/** /**
* Low priority task queue handler * job queue handler (for use in interrupts to do longer stuff on a thread)
*
* @param argument
*/
void TaskSchedLP (const void * argument)
{
dbg("> Low priority queue task started!");
struct sched_que_item job;
while (1) {
xQueueReceive(queSchedLPHandle, &job, osWaitForever);
assert_param(job.cb != NULL);
job.cb(&job);
}
}
/**
* High priority task queue handler
* *
* @param argument * @param argument
*/ */
void TaskSchedHP (const void * argument) void TaskJobQueue(const void *argument)
{ {
dbg("> High priority queue task started!"); dbg("> High priority queue task started!");
struct sched_que_item job; struct sched_que_item job;
while (1) { while (1) {
xQueueReceive(queSchedHPHandle, &job, osWaitForever); xQueueReceive(queSchedHandle, &job, osWaitForever);
assert_param(job.cb != NULL); assert_param(job.cb != NULL);
job.cb(&job); job.cb(&job);

@ -8,22 +8,13 @@
#include "platform.h" #include "platform.h"
#include "sched_queue.h" #include "sched_queue.h"
enum task_sched_prio {
TSK_SCHED_LOW = 0,
TSK_SCHED_HIGH = 1,
};
#if USE_STACK_MONITOR #if USE_STACK_MONITOR
extern volatile uint32_t jobQueHighWaterMarkHP; extern volatile uint32_t jobQueHighWaterMark;
extern volatile uint32_t jobQueHighWaterMarkLP;
#endif #endif
extern osThreadId tskSchedLPHandle; extern osThreadId tskJobRunnerHandle;
void TaskSchedLP (const void * argument); void TaskJobQueue(const void *argument);
extern osThreadId tskSchedHPHandle;
void TaskSchedHP (const void * argument);
void scheduleJob(Job *job, enum task_sched_prio prio); void scheduleJob(Job *job);
#endif //GEX_TASK_SCHED_H #endif //GEX_TASK_SCHED_H

@ -14,7 +14,7 @@ struct stackhandle {
uint32_t len; uint32_t len;
}; };
#define STACK_NUM 16 #define STACK_NUM 8
static uint32_t nextidx = 0; static uint32_t nextidx = 0;
static struct stackhandle stacks[STACK_NUM]; static struct stackhandle stacks[STACK_NUM];
@ -64,9 +64,9 @@ void stackmon_dump(void)
); );
} }
PUTS("\033[36m>> QUEUES\033[m\r\n"); PUTS("\033[36m>> JOB QUEUE\033[m\r\n");
PRINTF(" Used slots: \033[33mHP %"PRIu32", LP %"PRIu32"\033[m\r\n", PRINTF(" Used slots: \033[33m%"PRIu32"\033[m\r\n",
jobQueHighWaterMarkHP, jobQueHighWaterMarkLP); jobQueHighWaterMark);
PRINTF("\033[1m---------------------------\033[m\r\n\r\n"); PRINTF("\033[1m---------------------------\033[m\r\n\r\n");
} }

Loading…
Cancel
Save