Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support intertask message benchmark for FreeRTOS #15

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/common/bench_message_queue_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ void bench_message_queue_init(void *arg)

for (i = 1; i <= ITERATIONS; i++) {
gather_send_context_switch_stats(MAIN_PRIORITY, i);
bench_collect_resources();
}

/* Send one message, so the message queue is full */
Expand All @@ -203,6 +204,7 @@ void bench_message_queue_init(void *arg)

for (i = 1; i <= ITERATIONS; i++) {
gather_receive_context_switch_stats(MAIN_PRIORITY, i);
bench_collect_resources();
}

bench_message_queue_receive(MQ_ID, msg_rcv_buf, MSG_LEN);
Expand Down
55 changes: 54 additions & 1 deletion src/freertos/bench_porting_layer_freertos.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
#define MAX_THREADS 10
#define STACK_SIZE (configMINIMAL_STACK_SIZE + 200)
#define MAX_MUTEXES 5

#define MAX_QUEUES 1
#define QUEUE_SIZE (1)

static SemaphoreHandle_t semaphores[MAX_SEMAPHORES];
static StaticSemaphore_t semaphore_buffer[MAX_SEMAPHORES];
Expand All @@ -43,6 +44,10 @@ static int threads_to_remove_idx;
static SemaphoreHandle_t to_remove_sem;
static StaticSemaphore_t to_remove_sem_buf;

static QueueHandle_t queues[MAX_QUEUES];
static uint8_t queue_storage[MAX_QUEUES][QUEUE_SIZE];
static StaticQueue_t queue_buffer[MAX_QUEUES];

#define benchmark_task_PRIORITY (configMAX_PRIORITIES - 1)

void bench_test_init(void (*test_init_function)(void *))
Expand Down Expand Up @@ -271,6 +276,54 @@ void bench_collect_resources(void)
}
}

int bench_message_queue_create(int mq_id, const char *mq_name,
size_t msg_max_num, size_t msg_max_len)
{
configASSERT(msg_max_len <= QUEUE_SIZE);

queues[mq_id] = xQueueCreateStatic(msg_max_num, msg_max_len,
queue_storage[mq_id], &queue_buffer[mq_id]);

if (queues[mq_id] == NULL) {
return BENCH_ERROR;
}

return BENCH_SUCCESS;
}

int bench_message_queue_send(int mq_id, char *msg_ptr, size_t msg_len)
{
BaseType_t ret;

ret = xQueueSend(queues[mq_id], msg_ptr, portMAX_DELAY);

if (ret != pdPASS) {
return BENCH_ERROR;
}

return BENCH_SUCCESS;
}

int bench_message_queue_receive(int mq_id, char *msg_ptr, size_t msg_len)
{
BaseType_t ret;

ret = xQueueReceive(queues[mq_id], msg_ptr, portMAX_DELAY);

if (ret != pdPASS) {
return BENCH_ERROR;
}

return BENCH_SUCCESS;
}

int bench_message_queue_delete(int mq_id, const char *mq_name)
{
vQueueDelete(queues[mq_id]);

return BENCH_SUCCESS;
}

/*
* The following items are necessary as SUPPORT_STATIC_ALLOCATION is 1.
* This means that the application must define the necessary task
Expand Down