⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cxqrmv.c

📁 上传一个带源代码的嵌入式实时多任务操作系统CMX
💻 C
字号:
/*********************************************************

Copyright (c) CMX Company. 1999. All rights reserved

*********************************************************/
/* version 5.30 */

#define CMXMODULE 1

#include <cxfuncs.h>	/* get cmx include header file */
#include <cxextern.h>	/* get cmx include header file */

#if (defined(CMXTRACKER) || defined(WINTRACKER))
#include <cmxtrack.h>	/* get cmx include header file */
#endif

/********************************************************
	test: if testing for less then 0 then pointer = num_slots - 1
			if testing for equal to num_slots then pointer = 0

	when removing from top
	decrement head and test
	remove from where head points

	when removing from bottom
	remove from where tail points
	increment tail and test

 top = 0: remove from bottom
 top = 1: remove from top

*********************************************************/

byte K_I_Que_Get_Common(byte queuenum,void *byteptr,sign_word16 top)
{
	QUEHDR *queue_ptr;

	queue_ptr = &queue[queuenum];	/* get address of proper queue handler. */
	if (queuenum >= MAX_QUEUES || (!queue_ptr->size_slot))
		{
#if (defined(CMXTRACKER) || defined(WINTRACKER))
		if (CMXTRACKER_ON)
			{
			cmxtracker_in2(CXQRMV_K_ERROR,queuenum);
			}
#endif
		return(K_ERROR);
		}
	K_I_Disable_Sched();	/* set task block */
	/* see if queue_ptr has any slots filled */
	if (!(queue_ptr->queue_cnt))
		{
#if (defined(CMXTRACKER) || defined(WINTRACKER))
		if (CMXTRACKER_ON)
			{
			cmxtracker_in2(CXQRMV_EMPTY,queuenum);
			}
#endif
		K_I_Func_Return();
		return(K_ERROR);	/* no, return error */
		}
	if (top)	/* see if request was to remove top slot contents */
		{
		/* decrement head and test to see if head less then 0 */
		if (--queue_ptr->head < 0)
			queue_ptr->head = (queue_ptr->num_slots - 1);

		top = queue_ptr->head;	/* top will now be our index into array. */
		}
	else
		{
		/* request was to remove from bottom slot */

		top = queue_ptr->tail;	/* top will now be our index into array. */

		/* see if tail pointer has reached it's maximum count and set
			to 0, if so */
		if (++queue_ptr->tail == queue_ptr->num_slots)
			queue_ptr->tail = 0;
		}
		/* K_I_Copy = dest,source,count */
		K_I_Copy(byteptr,(&(queue_ptr->base_ptr[top *
			queue_ptr->size_slot])),queue_ptr->size_slot);
#if (defined(CMXTRACKER) || defined(WINTRACKER))
		if (CMXTRACKER_ON)
			{
			cmxtracker_in2(CXQRMV_K_OK,queuenum);
			}
#endif
	/* see if queue_ptr now empty */
	if (--queue_ptr->queue_cnt)
		{
		K_I_Func_Return();	/* no, release task block */
		return(K_OK);	/* return good operation */
		}
	K_I_Func_Return();		/* yes, queue empty, release task block */
	return(K_QUE_EMPTY);	/* return warning that queue now empty */
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -