aboutsummaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
Diffstat (limited to 'framework')
-rw-r--r--framework/src/fwk_multi_thread.c51
-rw-r--r--framework/test/test_fwk_multi_thread_create.c3
2 files changed, 12 insertions, 42 deletions
diff --git a/framework/src/fwk_multi_thread.c b/framework/src/fwk_multi_thread.c
index 6d27b898..49e2172d 100644
--- a/framework/src/fwk_multi_thread.c
+++ b/framework/src/fwk_multi_thread.c
@@ -6,7 +6,6 @@
*/
#include <cmsis_os2.h>
-#include <rtx_os.h>
#include <internal/fwk_id.h>
#include <internal/fwk_module.h>
@@ -56,29 +55,6 @@ static const char err_msg_func[] = "[FWK] Error %d in %s";
*/
/*
- * Initialize the attributes of thread.
- *
- * \param[out] attr Thread's attributes.
- *
- * \retval FWK_SUCCESS The initialization succeeded.
- * \retval FWK_E_NOMEM A memory allocation failed.
- */
-static int init_thread_attr(osThreadAttr_t *attr)
-{
- attr->name = "";
- attr->attr_bits = osThreadDetached;
- attr->cb_size = osRtxThreadCbSize;
- attr->cb_mem = fwk_mm_calloc(1, attr->cb_size);
-
- attr->stack_size = FMW_STACK_SIZE;
- attr->stack_mem = fwk_mm_calloc(1, attr->stack_size);
-
- attr->priority = osPriorityNormal;
-
- return FWK_SUCCESS;
-}
-
-/*
* Put back an event into the queue of free events.
*
* \param event Pointer to the event.
@@ -628,7 +604,10 @@ int __fwk_thread_init(size_t event_count)
{
int status;
struct fwk_event *event_table, *event_table_end, *event;
- osThreadAttr_t thread_attr;
+
+ osThreadAttr_t thread_attr = {
+ .stack_size = FMW_STACK_SIZE,
+ };
fwk_interrupt_global_enable();
status = osKernelInitialize();
@@ -649,10 +628,6 @@ int __fwk_thread_init(size_t event_count)
fwk_list_push_tail(&ctx.event_free_queue,
&event->slist_node);
- status = init_thread_attr(&thread_attr);
- if (status != FWK_SUCCESS)
- goto error;
-
ctx.common_thread_ctx.os_thread_id = osThreadNew(common_thread_function,
&ctx.common_thread_ctx, &thread_attr);
if (ctx.common_thread_ctx.os_thread_id == NULL) {
@@ -661,12 +636,9 @@ int __fwk_thread_init(size_t event_count)
}
/* Initialize the logging thread */
-
- status = init_thread_attr(&thread_attr);
- if (status != FWK_SUCCESS)
- goto error;
-
- thread_attr.priority = osPriorityLow;
+ thread_attr = (osThreadAttr_t){
+ .priority = osPriorityLow,
+ };
ctx.log_thread_id = osThreadNew(logging_thread, NULL, &thread_attr);
if (ctx.log_thread_id == NULL) {
@@ -732,7 +704,10 @@ int fwk_thread_create(fwk_id_t id)
{
int status;
struct __fwk_thread_ctx **p_thread_ctx, *thread_ctx;
- osThreadAttr_t thread_attr;
+
+ osThreadAttr_t thread_attr = {
+ .stack_size = FMW_STACK_SIZE,
+ };
if (!ctx.initialized) {
status = FWK_E_INIT;
@@ -748,10 +723,6 @@ int fwk_thread_create(fwk_id_t id)
goto error;
}
- status = init_thread_attr(&thread_attr);
- if (status != FWK_SUCCESS)
- goto error;
-
if ((ctx.running) || (*p_thread_ctx != NULL)) {
status = FWK_E_STATE;
goto error;
diff --git a/framework/test/test_fwk_multi_thread_create.c b/framework/test/test_fwk_multi_thread_create.c
index 5fbf6948..cc3abb08 100644
--- a/framework/test/test_fwk_multi_thread_create.c
+++ b/framework/test/test_fwk_multi_thread_create.c
@@ -172,7 +172,6 @@ static int test_suite_setup(void)
static void test_case_setup(void)
{
-
fwk_mm_calloc_return_null = UINT_MAX;
fwk_mm_calloc_call_count = 0;
fwk_interrupt_get_current_return_val = FWK_SUCCESS;
@@ -241,7 +240,7 @@ static void test_create_thread_memory_allocation_failed(void)
fwk_id_t id = FWK_ID_MODULE(0x1);
/* Thread memory allocation failed */
- fwk_mm_calloc_return_null = 3;
+ fwk_mm_calloc_return_null = 1;
status = fwk_thread_create(id);
assert(status == FWK_E_NOMEM);
}