You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by we...@apache.org on 2016/02/18 02:03:34 UTC
[2/3] incubator-mynewt-larva git commit: MYNEWT-80: remove os_mutex
and os_sem delete API. Remove test cases from test suite as well
MYNEWT-80: remove os_mutex and os_sem delete API. Remove test cases from test suite as well
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/f1e3970a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/f1e3970a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/f1e3970a
Branch: refs/heads/develop
Commit: f1e3970afb8480106287b7ca22f97296ff23533c
Parents: cf93bdc
Author: wes3 <wi...@micosa.io>
Authored: Tue Feb 16 14:07:19 2016 -0800
Committer: wes3 <wi...@micosa.io>
Committed: Wed Feb 17 17:00:52 2016 -0800
----------------------------------------------------------------------
libs/os/include/os/os_mutex.h | 3 --
libs/os/include/os/os_sem.h | 3 --
libs/os/src/os_mutex.c | 62 -------------------------------------
libs/os/src/os_sem.c | 63 --------------------------------------
libs/os/src/test/mutex_test.c | 2 --
libs/os/src/test/sem_test.c | 13 --------
6 files changed, 146 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f1e3970a/libs/os/include/os/os_mutex.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/os_mutex.h b/libs/os/include/os/os_mutex.h
index f03d4da..46c15f2 100644
--- a/libs/os/include/os/os_mutex.h
+++ b/libs/os/include/os/os_mutex.h
@@ -56,7 +56,4 @@ os_error_t os_mutex_release(struct os_mutex *mu);
/* Pend (wait) for a mutex */
os_error_t os_mutex_pend(struct os_mutex *mu, uint32_t timeout);
-/* Delete a mutex */
-os_error_t os_mutex_delete(struct os_mutex *mu);
-
#endif /* _OS_MUTEX_H_ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f1e3970a/libs/os/include/os/os_sem.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/os_sem.h b/libs/os/include/os/os_sem.h
index 0396e96..0d44f91 100644
--- a/libs/os/include/os/os_sem.h
+++ b/libs/os/include/os/os_sem.h
@@ -49,7 +49,4 @@ os_error_t os_sem_release(struct os_sem *sem);
/* Pend (wait) for a semaphore */
os_error_t os_sem_pend(struct os_sem *sem, uint32_t timeout);
-/* Delete a semaphore */
-os_error_t os_sem_delete(struct os_sem *sem);
-
#endif /* _OS_MUTEX_H_ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f1e3970a/libs/os/src/os_mutex.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os_mutex.c b/libs/os/src/os_mutex.c
index 454f6ab..b54f7e5 100644
--- a/libs/os/src/os_mutex.c
+++ b/libs/os/src/os_mutex.c
@@ -234,65 +234,3 @@ os_mutex_pend(struct os_mutex *mu, uint32_t timeout)
return rc;
}
-/**
- * os mutex delete
- *
- * Delete a mutex.
- *
- * @param mu Pointer to mutex to delete
- *
- * @return os_error_t
- * OS_INVALID_PARM Mutex passed in was NULL.
- * OS_OK no error.
- */
-os_error_t
-os_mutex_delete(struct os_mutex *mu)
-{
- os_sr_t sr;
- struct os_task *current;
- struct os_task *rdy;
-
- /* OS must be started to call this function */
- if (!g_os_started) {
- return (OS_NOT_STARTED);
- }
-
- /* Check for valid mutex */
- if (!mu) {
- return OS_INVALID_PARM;
- }
-
- /* Get currently running task */
- current = os_sched_get_current_task();
-
- OS_ENTER_CRITICAL(sr);
-
- /* Restore owner task's priority. */
- if (mu->mu_level != 0) {
- if (mu->mu_owner->t_prio != mu->mu_prio) {
- /* We have to resort the ready list if this task is ready */
- mu->mu_owner->t_prio = mu->mu_prio;
- os_sched_resort(mu->mu_owner);
- }
- }
-
- /* Now, go through all the tasks waiting on the mutex */
- while (!SLIST_EMPTY(&mu->mu_head)) {
- rdy = SLIST_FIRST(&mu->mu_head);
- assert(rdy->t_obj);
- os_sched_wakeup(rdy);
- }
-
- /* Is there a task that is ready that is higher priority than us? */
- rdy = os_sched_next_task();
- if (rdy != current) {
- /* Re-schedule */
- OS_EXIT_CRITICAL(sr);
- os_sched(rdy, 0);
- } else {
- OS_EXIT_CRITICAL(sr);
- }
-
- return OS_OK;
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f1e3970a/libs/os/src/os_sem.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os_sem.c b/libs/os/src/os_sem.c
index f96efa7..0140c53 100644
--- a/libs/os/src/os_sem.c
+++ b/libs/os/src/os_sem.c
@@ -210,66 +210,3 @@ os_sem_pend(struct os_sem *sem, uint32_t timeout)
return rc;
}
-/**
- * os sem delete
- *
- * Delete a semaphore.
- *
- * @param mu Pointer to semaphore to delete
- *
- * @return os_error_t
- * OS_INVALID_PARM Semaphore passed in was NULL.
- * OS_OK no error.
- */
-os_error_t
-os_sem_delete(struct os_sem *sem)
-{
- int resched;
- os_sr_t sr;
- struct os_task *current;
- struct os_task *rdy;
-
- /* OS must be started in order to call this function */
- if (!g_os_started) {
- return (OS_NOT_STARTED);
- }
-
- /* Check for valid semaphore */
- if (!sem) {
- return OS_INVALID_PARM;
- }
-
- /* Get currently running task */
- resched = 0;
- current = os_sched_get_current_task();
-
- OS_ENTER_CRITICAL(sr);
-
- /* Remove all tokens from semaphore */
- sem->sem_tokens = 0;
-
- /* Any tasks waiting? */
- rdy = SLIST_FIRST(&sem->sem_head);
- if (rdy) {
- /* If higher priority than current task, we must resched */
- if (current->t_prio > rdy->t_prio) {
- resched = 1;
- }
-
- /* Now, go through all the tasks waiting on the semaphore */
- while (rdy != NULL) {
- os_sched_wakeup(rdy);
- rdy = SLIST_FIRST(&sem->sem_head);
- }
- }
-
- OS_EXIT_CRITICAL(sr);
-
- /* Re-schedule if needed*/
- if (resched) {
- os_sched(rdy, 0);
- }
-
- return OS_OK;
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f1e3970a/libs/os/src/test/mutex_test.c
----------------------------------------------------------------------
diff --git a/libs/os/src/test/mutex_test.c b/libs/os/src/test/mutex_test.c
index ff5e016..ef6a08d 100644
--- a/libs/os/src/test/mutex_test.c
+++ b/libs/os/src/test/mutex_test.c
@@ -78,7 +78,6 @@ mutex_test_basic_handler(void *arg)
/* Test some error cases */
TEST_ASSERT(os_mutex_init(NULL) == OS_INVALID_PARM);
- TEST_ASSERT(os_mutex_delete(NULL) == OS_INVALID_PARM);
TEST_ASSERT(os_mutex_release(NULL) == OS_INVALID_PARM);
TEST_ASSERT(os_mutex_pend(NULL, 0) == OS_INVALID_PARM);
@@ -190,7 +189,6 @@ mutex_test2_task14_handler(void *arg)
}
if (g_mutex_test == 4) {
- os_mutex_delete(&g_mutex1);
os_time_delay(150);
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f1e3970a/libs/os/src/test/sem_test.c
----------------------------------------------------------------------
diff --git a/libs/os/src/test/sem_test.c b/libs/os/src/test/sem_test.c
index e0f60b6..ec79185 100644
--- a/libs/os/src/test/sem_test.c
+++ b/libs/os/src/test/sem_test.c
@@ -126,7 +126,6 @@ sem_test_basic_handler(void *arg)
/* Test some error cases */
TEST_ASSERT(os_sem_init(NULL, 1) == OS_INVALID_PARM);
- TEST_ASSERT(os_sem_delete(NULL) == OS_INVALID_PARM);
TEST_ASSERT(os_sem_release(NULL) == OS_INVALID_PARM);
TEST_ASSERT(os_sem_pend(NULL, 1) == OS_INVALID_PARM);
@@ -177,18 +176,6 @@ sem_test_basic_handler(void *arg)
"Task: task=%p prio=%u\n", sem_test_sem_to_s(sem), t,
t->t_prio);
- /* "Delete" it */
- err = os_sem_delete(sem);
- TEST_ASSERT(err == 0,
- "Could not delete semaphore (err=%d)", err);
-
- /* Check semaphore internals */
- TEST_ASSERT(sem->sem_tokens == 0 && SLIST_EMPTY(&sem->sem_head),
- "Semaphore internals wrong after deleting semaphore\n"
- "%s\n"
- "Task: task=%p prio=%u\n", sem_test_sem_to_s(sem), t,
- t->t_prio);
-
os_test_restart();
}