Lines Matching full:mutex

15 static pthread_mutex_t mutex;  variable
24 rc = pthread_mutex_trylock(&mutex); in normal_mutex_entry()
32 TC_PRINT("mutex lock is taken\n"); in normal_mutex_entry()
33 zassert_false(pthread_mutex_unlock(&mutex), "mutex unlock is failed"); in normal_mutex_entry()
39 zassert_false(pthread_mutex_lock(&mutex), "mutex is not taken"); in recursive_mutex_entry()
40 zassert_false(pthread_mutex_lock(&mutex), "mutex is not taken 2nd time"); in recursive_mutex_entry()
41 TC_PRINT("recursive mutex lock is taken\n"); in recursive_mutex_entry()
42 zassert_false(pthread_mutex_unlock(&mutex), "mutex is not unlocked"); in recursive_mutex_entry()
43 zassert_false(pthread_mutex_unlock(&mutex), "mutex is not unlocked"); in recursive_mutex_entry()
58 zassert_ok(pthread_mutexattr_settype(&mut_attr, type), "setting mutex type is failed"); in test_mutex_common()
59 zassert_ok(pthread_mutex_init(&mutex, &mut_attr), "mutex initialization is failed"); in test_mutex_common()
62 "reading mutex type is failed"); in test_mutex_common()
71 "reading mutex protocol is failed"); in test_mutex_common()
74 zassert_ok(pthread_mutex_lock(&mutex)); in test_mutex_common()
76 zassert_equal(actual_type, type, "mutex type is not normal"); in test_mutex_common()
77 zassert_equal(protocol, PTHREAD_PRIO_NONE, "mutex protocol is not prio_none"); in test_mutex_common()
82 zassert_ok(pthread_mutex_unlock(&mutex)); in test_mutex_common()
85 zassert_ok(pthread_mutex_destroy(&mutex), "Destroying mutex is failed"); in test_mutex_common()
88 ZTEST(mutex, test_mutex_prioceiling_stubs) in ZTEST() argument
103 * @details Mutex type is setup as normal. pthread_mutex_trylock
104 * and pthread_mutex_lock are tested with mutex type being
107 ZTEST(mutex, test_mutex_normal) in ZTEST() argument
115 * @details Mutex type is setup as recursive. mutex will be locked
119 ZTEST(mutex, test_mutex_recursive) in ZTEST() argument
125 * @brief Test to demonstrate limited mutex resources
129 ZTEST(mutex, test_mutex_resource_exhausted) in ZTEST() argument
135 zassert_ok(pthread_mutex_init(&m[i], NULL), "failed to init mutex %zu", i); in ZTEST()
141 "should not have initialized mutex %zu", i); in ZTEST()
144 zassert_ok(pthread_mutex_destroy(&m[i - 1]), "failed to destroy mutex %zu", i - 1); in ZTEST()
149 * @brief Test to that there are no mutex resource leaks
153 ZTEST(mutex, test_mutex_resource_leak) in ZTEST() argument
158 zassert_ok(pthread_mutex_init(&m, NULL), "failed to init mutex %zu", i); in ZTEST()
159 zassert_ok(pthread_mutex_destroy(&m), "failed to destroy mutex %zu", i); in ZTEST()
192 ZTEST(mutex, test_mutex_timedlock) in ZTEST() argument
197 zassert_ok(pthread_mutex_init(&mutex, NULL)); in ZTEST()
200 zassert_ok(pthread_mutex_lock(&mutex)); in ZTEST()
201 zassert_ok(pthread_create(&th, NULL, test_mutex_timedlock_fn, &mutex)); in ZTEST()
208 zassert_ok(pthread_create(&th, NULL, test_mutex_timedlock_fn, &mutex)); in ZTEST()
211 zassert_ok(pthread_mutex_unlock(&mutex)); in ZTEST()
216 zassert_ok(pthread_mutex_destroy(&mutex)); in ZTEST()
229 ZTEST_SUITE(mutex, NULL, NULL, before, NULL, NULL);