Exemple #1
0
/*test cases*/
void test_msgq_purge_when_put(void)
{
	struct k_msgq msgq;
	int ret;

	k_msgq_init(&msgq, tbuffer, MSG_SIZE, MSGQ_LEN);

	/*fill the queue to full*/
	for (int i = 0; i < MSGQ_LEN; i++) {
		ret = k_msgq_put(&msgq, (void *)&data[i], K_NO_WAIT);
		zassert_equal(ret, 0, NULL);
	}
	/*create another thread waiting to put msg*/
	k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
				     tThread_entry, &msgq, NULL, NULL,
				     K_PRIO_PREEMPT(0), 0, 0);
	k_sleep(TIMEOUT >> 1);
	/**TESTPOINT: msgq purge while another thread waiting to put msg*/
	k_msgq_purge(&msgq);
	k_sleep(TIMEOUT >> 1);
	k_thread_abort(tid);

	/*verify msg put after purge*/
	for (int i = 0; i < MSGQ_LEN; i++) {
		ret = k_msgq_put(&msgq, (void *)&data[i], K_NO_WAIT);
		zassert_equal(ret, 0, NULL);
	}
}
Exemple #2
0
/* SimpleLink driver code can call this from ISR or task context: */
_SlReturnVal_t os_Spawn(P_OS_SPAWN_ENTRY pEntry, void *pValue,
			unsigned long flags)
{
	tSimpleLinkSpawnMsg slMsg;
	_SlReturnVal_t retval;

	slMsg.pEntry = pEntry;
	slMsg.pValue = pValue;

	if (0 == k_msgq_put(&spawn_msgq, &slMsg, K_NO_WAIT)) {
		retval = OS_OK;
	}
	else {
		retval = -1;
		__ASSERT(retval == OS_OK,
			 "os_Spawn: Failed to k_msgq_put failed\r\n");

	}

	return retval;
}
Exemple #3
0
static void tThread_entry(void *p1, void *p2, void *p3)
{
	int ret = k_msgq_put((struct k_msgq *)p1, (void *)&data[0], TIMEOUT);

	zassert_equal(ret, -ENOMSG, NULL);
}