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

Fix #853, remove OS_TaskRegister #926

Merged
merged 1 commit into from
Mar 30, 2021
Merged
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
6 changes: 0 additions & 6 deletions src/examples/tasking-example/tasking-example.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ void task_1(void)

OS_printf("Starting task 1\n");

OS_TaskRegister();

while (1)
{
status = OS_MutSemTake(mutex_id);
Expand Down Expand Up @@ -171,8 +169,6 @@ void task_2(void)

OS_printf("Starting task 2\n");

OS_TaskRegister();

while (1)
{
status = OS_MutSemTake(mutex_id);
Expand Down Expand Up @@ -220,8 +216,6 @@ void task_3(void)

OS_printf("Starting task 3\n");

OS_TaskRegister();

while (1)
{
status = OS_QueueGet(msgq_id, (void *)&data_received, MSGQ_SIZE, &data_size, OS_PEND);
Expand Down
12 changes: 0 additions & 12 deletions src/os/inc/osapi-task.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,6 @@ int32 OS_TaskDelay(uint32 millisecond);
*/
int32 OS_TaskSetPriority(osal_id_t task_id, osal_priority_t new_priority);

/*-------------------------------------------------------------------------------------*/
/**
* @brief Obsolete
* @deprecated Explicit registration call no longer needed
*
* Obsolete function retained for compatibility purposes.
* Does Nothing in the current implementation.
*
* @return #OS_SUCCESS (always), see @ref OSReturnCodes
*/
int32 OS_TaskRegister(void);

/*-------------------------------------------------------------------------------------*/
/**
* @brief Obtain the task id of the calling task
Expand Down
2 changes: 1 addition & 1 deletion src/os/shared/inc/os-shared-task.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ int32 OS_TaskGetInfo_Impl(const OS_object_token_t *token, OS_task_prop_t *task_p
Purpose: Perform registration actions after new task creation

NOTE: This is invoked via the OS_TaskEntryPoint() immediately
after new task creation, not through OS_TaskRegister() API
after new task creation

Returns: OS_SUCCESS on success, or relevant error code
------------------------------------------------------------------*/
Expand Down
19 changes: 0 additions & 19 deletions src/os/shared/src/osapi-task.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,25 +329,6 @@ int32 OS_TaskSetPriority(osal_id_t task_id, osal_priority_t new_priority)
return return_code;
} /* end OS_TaskSetPriority */

/*----------------------------------------------------------------
*
* Function: OS_TaskRegister
*
* Purpose: Implemented per public OSAL API
* See description in API and header file for detail
*
*-----------------------------------------------------------------*/
int32 OS_TaskRegister(void)
{
OS_object_token_t token;

/*
* Just to retain compatibility (really, only the unit test cares)
* this will return NON success when called from a non-task context
*/
return OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, OS_TaskGetId_Impl(), &token);
} /* end OS_TaskRegister */

/*----------------------------------------------------------------
*
* Function: OS_TaskGetId
Expand Down
3 changes: 0 additions & 3 deletions src/tests/bin-sem-flush-test/bin-sem-flush-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ void task_1(void)
int counter = 0;

OS_printf("Starting task 1\n");
OS_TaskRegister();

OS_printf("TASK 1: Waiting on the semaphore\n");
status = OS_BinSemTake(bin_sem_id);
Expand Down Expand Up @@ -101,7 +100,6 @@ void task_2(void)

task_2_failures = 0;
OS_printf("Starting task 2\n");
OS_TaskRegister();

OS_printf("TASK 2: Waiting on the semaphore\n");
status = OS_BinSemTake(bin_sem_id);
Expand Down Expand Up @@ -139,7 +137,6 @@ void task_3(void)
int counter = 0;

OS_printf("Starting task 3\n");
OS_TaskRegister();

OS_printf("TASK 3: Waiting on the semaphore\n");
status = OS_BinSemTake(bin_sem_id);
Expand Down
2 changes: 0 additions & 2 deletions src/tests/bin-sem-test/bin-sem-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ void task_1(void)

OS_printf("Starting task 1\n");

OS_TaskRegister();

OS_printf("Delay for 1 second before starting\n");
OS_TaskDelay(1000);

Expand Down
2 changes: 0 additions & 2 deletions src/tests/bin-sem-timeout-test/bin-sem-timeout-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ void task_1(void)

OS_printf("Starting task 1\n");

OS_TaskRegister();

OS_printf("Delay for 1 second before starting\n");
OS_TaskDelay(1000);

Expand Down
3 changes: 0 additions & 3 deletions src/tests/count-sem-test/count-sem-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ void task_1(void)
uint32 status;

OS_printf("Starting task 1\n");
OS_TaskRegister();

while (1)
{
Expand Down Expand Up @@ -100,7 +99,6 @@ void task_2(void)
uint32 status;

OS_printf("Starting task 2\n");
OS_TaskRegister();

while (1)
{
Expand All @@ -126,7 +124,6 @@ void task_3(void)
uint32 status;

OS_printf("Starting task 3\n");
OS_TaskRegister();

while (1)
{
Expand Down
3 changes: 0 additions & 3 deletions src/tests/mutex-test/mutex-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ void task_1(void)
uint32 status;

OS_printf("Starting task 1\n");
OS_TaskRegister();

while (1)
{
Expand Down Expand Up @@ -112,7 +111,6 @@ void task_2(void)
uint32 status;

OS_printf("Starting task 2\n");
OS_TaskRegister();

while (1)
{
Expand Down Expand Up @@ -165,7 +163,6 @@ void task_3(void)
uint32 status;

OS_printf("Starting task 3\n");
OS_TaskRegister();

while (1)
{
Expand Down
2 changes: 0 additions & 2 deletions src/tests/osal-core-test/osal-core-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ void UtTest_Setup(void)

void task_generic_no_exit(void)
{
OS_TaskRegister();

while (1)
{
OS_TaskDelay(100);
Expand Down
2 changes: 0 additions & 2 deletions src/tests/queue-test/queue-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ void task_1(void)

OS_printf("Starting task 1\n");

OS_TaskRegister();

OS_printf("Delay for 1 second before starting\n");
OS_TaskDelay(1000);

Expand Down
2 changes: 0 additions & 2 deletions src/tests/sem-speed-test/sem-speed-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ void task_1(void)
uint32 status;

OS_printf("Starting task 1\n");
OS_TaskRegister();

while (task_1_work < SEMTEST_WORK_LIMIT)
{
Expand All @@ -123,7 +122,6 @@ void task_2(void)
uint32 status;

OS_printf("Starting task 2\n");
OS_TaskRegister();

while (task_2_work < SEMTEST_WORK_LIMIT)
{
Expand Down
12 changes: 0 additions & 12 deletions src/unit-test-coverage/shared/src/coveragetest-task.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,6 @@ void Test_OS_TaskSetPriority(void)

UtAssert_True(actual == expected, "OS_TaskSetPriority() (%ld) == OS_SUCCESS", (long)actual);
}
void Test_OS_TaskRegister(void)
{
/*
* Test Case For:
* int32 OS_TaskRegister (void)
*/
int32 expected = OS_SUCCESS;
int32 actual = OS_TaskRegister();

UtAssert_True(actual == expected, "OS_TaskRegister() (%ld) == OS_SUCCESS", (long)actual);
}
void Test_OS_TaskGetId(void)
{
/*
Expand Down Expand Up @@ -360,7 +349,6 @@ void UtTest_Setup(void)
ADD_TEST(OS_TaskExit);
ADD_TEST(OS_TaskDelay);
ADD_TEST(OS_TaskSetPriority);
ADD_TEST(OS_TaskRegister);
ADD_TEST(OS_TaskGetId);
ADD_TEST(OS_TaskGetIdByName);
ADD_TEST(OS_TaskGetInfo);
Expand Down
114 changes: 0 additions & 114 deletions src/unit-tests/oscore-test/ut_oscore_task_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ void generic_test_task(void)
osal_id_t task_id;
OS_task_prop_t task_prop;

OS_TaskRegister();

task_id = OS_TaskGetId();
OS_TaskGetInfo(task_id, &task_prop);

Expand Down Expand Up @@ -332,8 +330,6 @@ void delete_handler_test_task(void)
osal_id_t task_id;
OS_task_prop_t task_prop;

OS_TaskRegister();

task_id = OS_TaskGetId();
OS_TaskGetInfo(task_id, &task_prop);

Expand Down Expand Up @@ -438,8 +434,6 @@ void exit_test_task(void)
osal_id_t task_id;
OS_task_prop_t task_prop;

OS_TaskRegister();

task_id = OS_TaskGetId();
OS_TaskGetInfo(task_id, &task_prop);

Expand Down Expand Up @@ -657,121 +651,13 @@ void UT_os_task_set_priority_test()
return;
}

/*--------------------------------------------------------------------------------*
** Syntax: OS_TaskRegister
** Purpose: Registers the task, performs application- and OS-specific inits
** Parameters: To-be-filled-in
** Returns: OS_ERR_INVALID_ID if the id passed in is not a valid task id
** OS_ERROR if the OS call failed
** OS_SUCCESS if succeeded
**--------------------------------------------------------------------------------*/
void register_test_task(void)
{
osal_id_t task_id;
OS_task_prop_t task_prop;

g_task_result = OS_TaskRegister();

task_id = OS_TaskGetId();
OS_TaskGetInfo(task_id, &task_prop);

UtPrintf("Starting RegisterTest Task: %s\n", task_prop.name);
;

/*
** Release the semaphore so the main function can record the results of the test
** and clean up
*/
OS_BinSemGive(g_task_sync_sem);

for (;;)
{
OS_TaskDelay(1000);
}
}

/*--------------------------------------------------------------------------------*/

void UT_os_task_register_test(void)
{
int32 res = 0;
const char *testDesc;

/*-----------------------------------------------------*/
testDesc = "API not implemented";

res = OS_TaskRegister();
if (res == OS_ERR_NOT_IMPLEMENTED)
{
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA);
goto UT_os_task_register_test_exit_tag;
}

/*-----------------------------------------------------*/
testDesc = "#1 Invalid-ID-arg";

res = OS_TaskRegister();
if (res == OS_ERR_INVALID_ID)
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS);
else
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE);

/*-----------------------------------------------------*/
testDesc = "#2 OS-call-failure";

UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO);

/*-----------------------------------------------------*/
testDesc = "#3 Nominal";

/* Setup */
res = OS_BinSemCreate(&g_task_sync_sem, "TaskSync", 1, 0);
if (res != OS_SUCCESS)
{
testDesc = "#3 Nominal - Bin-Sem-Create failed";
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF);
}
else
{
OS_BinSemTake(g_task_sync_sem);

res = OS_TaskCreate(&g_task_ids[3], g_task_names[3], register_test_task, OSAL_STACKPTR_C(&g_task_stacks[3]),
sizeof(g_task_stacks[3]), OSAL_PRIORITY_C(UT_TASK_PRIORITY), 0);
if (res != OS_SUCCESS)
{
testDesc = "#3 Nominal - Task-Create failed";
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF);
}
else
{
/* Wait for the task to finish the test */
OS_BinSemTake(g_task_sync_sem);
/* Delay to let child task run */
OS_TaskDelay(500);

OS_TaskDelete(g_task_ids[3]);
res = OS_BinSemDelete(g_task_sync_sem);

if (g_task_result == OS_SUCCESS)
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS);
else
UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE);
}
}

UT_os_task_register_test_exit_tag:
return;
}

/*--------------------------------------------------------------------------------*/

void getid_test_task(void)
{
osal_id_t task_id;
OS_task_prop_t task_prop;

OS_TaskRegister();

task_id = OS_TaskGetId();
OS_TaskGetInfo(task_id, &task_prop);

Expand Down
1 change: 0 additions & 1 deletion src/unit-tests/oscore-test/ut_oscore_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ void UtTest_Setup(void)
UtTest_Add(UT_os_task_exit_test, UT_os_init_task_exit_test, NULL, "OS_TaskExit");
UtTest_Add(UT_os_task_delay_test, UT_os_init_task_delay_test, NULL, "OS_TaskDelay");
UtTest_Add(UT_os_task_set_priority_test, UT_os_init_task_set_priority_test, NULL, "OS_TaskSetPriority");
UtTest_Add(UT_os_task_register_test, UT_os_init_task_register_test, NULL, "OS_TaskRegister");
UtTest_Add(UT_os_task_get_id_test, UT_os_init_task_get_id_test, NULL, "OS_TaskGetId");
UtTest_Add(UT_os_task_get_id_by_name_test, UT_os_init_task_get_id_by_name_test, NULL, "OS_TaskGetIdByName");
UtTest_Add(UT_os_task_get_info_test, UT_os_init_task_get_info_test, NULL, "OS_TaskGetInfo");
Expand Down
Loading