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

📄 qpend.c

📁 VRTX操作系统
💻 C
字号:

/*

  IMPORTANT - USE OF THIS SOFTWARE IS SUBJECT TO LICENSE RESTRICTIONS
  CAREFULLY READ THIS LICENSE AGREEMENT BEFORE USING THE SOFTWARE
  
	************************************************************
	This license is a legal "Agreement" between you, the end user, either
	individually or as an authorized representative for the company purchasing 
	the license, and Mentor Graphics Corporation, Mentor Graphics (Ireland) 
	Limited, Mentor Graphics (Singapore) Private Limited, and its other 
	majority-owned subsidiaries worldwide ("Mentor Graphics") concerning 
	the use of Software. USE OF SOFTWARE INDICATES YOUR COMPLETE AND 
	UNCONDITIONAL ACCEPTANCE OF THE TERMS AND CONDITIONS SET FORTH IN THIS 
	AGREEMENT. If you do not agree to these terms and conditions, promptly 
	return Software and all accompanying items.
	************************************************************
	
	  LICENSE AGREEMENT
	  
		1. GRANT OF LIMITED LICENSE. The associated software programs, including
		any updates, modifications, revisions and copies, and documentation 
		("Software") are copyrighted, trade secret and confidential information 
		of Mentor Graphics or its licensors who maintain exclusive title to all 
		Software and retain all rights not expressly granted by this Agreement. 
		Mentor Graphics grants to you a limited, royalty-free, nontransferable, 
		nonexclusive license to use and modify binary and source code versions 
		of that portion of Software known as VRTXoc solely for Non-Commercial 
		Purposes. Mentor Graphics also grants to you a temporary, nontransferable, 
		nonexclusive license to use that portion of Software known as XRAY 
		Debugger solely: (a) in machine-readable, object-code form; (b) for 
		evaluation and or Non-Commercial Purposes; and (c) on the computer
		hardware authorized by Mentor Graphics. "Non-Commercial Purposes" means 
		internal use of  Software solely for educational, research, or 
		development purposes (including prototype design), and specifically 
		excluding, without limitation, any use in connection with any product 
		or service which generates revenue, goodwill, or anything of value. 
		Mentor Graphics does NOT grant you any right to duplicate or incorporate 
		copies of Software into any products for distribution or commercial 
		purposes without first executing a separate agreement, subject to 
		royalty provisions, with Mentor Graphics.  On ARM processors, such a 
		separate production license is not available except in conjunction with 
		silicon supplied by ARM silicon consortium members.
		
		  2. GRANT TO MENTOR GRAPHICS. You hereby grant Mentor Graphics a perpetual,
		  royalty-free, nonexclusive, worldwide license to (a) any and all 
		  modifications to  Software which result in functional improvements to 
		  the Software so Mentor Graphics may incorporate such modifications into 
		  future versions of any Mentor Graphics software and (b) methods or 
		  concepts embodied in such modifications to  Software.  These 
		  modifications and the methods and concepts embodied in them shall be 
		  promptly provided to Mentor Graphics.
		  
			3. RESTRICTIONS ON USE. You may copy Software only as reasonably necessary
			to support your authorized use. That portion of Software known as VRTXoc,
			including modifications, may also be copied for collaborative development
			purposes. Each copy must include all notices and legends embedded in 
			Software and affixed to its medium and container as received from Mentor 
			Graphics. All copies shall remain  property of Mentor Graphics or its 
			licensors. You shall not make Software available in any form to any person 
			or than persons who are subject to this Agreement and have agreed to its 
			terms. You shall take appropriate action to protect  confidentiality of 
			the Software and ensure that any person permitted access to Software does 
			not disclose it or use it except as permitted by this Agreement. You shall 
			not reverse-assemble, reverse-compile, reverse-engineer or in any way 
			derive from that portion of Software known as XRAY Debugger any source 
			code form. You may not sublicense, assign or orwise transfer Software, 
			this Agreement or the rights under it without Mentor Graphics' prior 
			written consent. The provisions of this section shall survive  termination 
			or expiration of this Agreement and may vary based on local law.
			
			  4. NO WARRANTY. SOFTWARE IS PROVIDED "AS IS" AND MENTOR GRAPHICS MAKES NO
			  WARRANTIES, EXPRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE OR ANY 
			  SERVICES PROVIDED UNDER THIS AGREEMENT. MENTOR GRAPHICS SPECIFICALLY 
			  DISCLAIMS ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
			  PARTICULAR PURPOSE.
			  
				5. LIMITATION OF LIABILITY. IN NO EVENT SHALL MENTOR GRAPHICS OR ITS
				LICENSORS BE LIABLE FOR ANY DAMAGES (INCLUDING INDIRECT, SPECIAL, 
				INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR LOST PROFITS OR SAVINGS) 
				WHETHER BASED ON CONTRACT, TORT OR ANY OTHER LEGAL THEORY, EVEN IF 
				MENTOR GRAPHICS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 
				MENTOR GRAPHICS OR ITS LICENSORS SHALL NOT BY LIABLE FOR ANY DAMAGES 
				RESULTING FROM OR IN CONNECTION WITH THE USE OF SOFTWARE IN THE DESIGN 
				OR OPERATION OF ANY APPLICATION WHERE THE FAILURE OR INACCURACY OF THE 
				PRODUCTS MIGHT CAUSE DEATH OR PERSONAL INJURY. YOU AGREE TO INDEMNIFY AND
				HOLD HARMLESS MENTOR GRAPHICS AND ITS LICENSORS FROM ANY CLAIMS, LOSS, 
				COST, DAMAGE, EXPENSE, OR LIABILITY, INCLUDING ATTORNEYS' FEES, ARISING 
				OUT OF OR IN CONNECTION WITH SUCH USE.
				
				  6. TERM. This Agreement remains effective until terminated. You may
				  terminate this Agreement at any time. This Agreement will automatically
				  terminate if you fail to comply with any term or condition of this 
				  Agreement.  The limited grant for use of that portion of Software known 
				  as XRAY Debugger will automatically expire at end of the limited term 
				  specified by Mentor Graphics.  Upon any termination or expiration, you 
				  agree to cease all use of Software and return it to Mentor Graphics or 
				  certify deletion and destruction of Software, including all copies.
				  
					7. EXPORT. Software is subject to regulation by local laws and United
					States government agencies, which prohibit export or diversion of 
					certain products, information about  products, and direct products of 
					the products to certain countries and certain persons. You agree that 
					you will not export in any manner any Software or direct product of 
					Software, without first obtaining all necessary approval from appropriate 
					local and United States government agencies.
					
					  8. RESTRICTED RIGHTS NOTICE. Software has been developed entirely at
					  private expense and is commercial computer software provided with 
					  RESTRICTED RIGHTS. Use, duplication or disclosure by  U.S. Government 
					  or a U.S. Government subcontractor is subject to  restrictions set 
					  forth in the license agreement under which Software was obtained pursuant 
					  to DFARS 227.7202-3(a) or as set forth in subparagraphs (c)(1) and (2) 
					  of Commercial Computer Software - Restricted Rights clause at FAR 
					  52.227-19, as applicable. Contractor/manufacturer is Mentor Graphics 
					  Corporation, 8005 Boeckman Road, Wilsonville, Oregon 97070 USA.
					  
						9. MISCELLANEOUS. This Agreement shall be governed by and construed under
						laws of Ireland if licensed in Israel, Egypt, South Africa or the European
						Union,  laws of Singapore if licensed in Japan, Singapore, China, Taiwan,
						Hong Kong, India or Korea and  laws of the state of Oregon if licensed in 
						the United States, Canada, Mexico, South America or anywhere else 
						worldwide if not orwise provided for in this section. This Agreement 
						contains the entire understanding between  parties relating to its subject 
						matter. This Agreement may only be modified in writing by you and an 
						authorized agent of Mentor Graphics. Any signed written agreement between 
						you and an authorized agent of Mentor Graphics relating to this subject 
						matter supersedes this Agreement.  Waiver of terms or excuse of breach 
						must be in writing and shall not constitute subsequent consent, waiver 
						or excuse. If any provision of this Agreement is held by a court of 
						competent jurisdiction to be void, invalid, unenforceable or illegal, 
						such provision shall be severed from this Agreement and  remaining
						provisions will remain in force and effect. The prevailing party in 
						any legal action regarding  subject matter of this Agreement shall 
						be entitled to recover, in addition to or relief, reasonable attorney's 
						fees and expenses.  
						
						  
*/
/***************************************************************************
*
*		Copyright (c) 1999 Mentor Graphics Corporation.
*
*
*
*
*
****************************************************************************
*/

#include "queue.h"
#include "kernel.h"
#include "task.h"
#include "processor.h"
#include "delay.h"
#include "q.h"

char *sc_qpend(int qid, unsigned long timeout, int *errp)
{
	cpu_interrupt_t ps;
	struct qentry *queue;
	struct tentry *tcbp;
	char *msg;
	
	if ((unsigned)qid < vmc_nqueue) {
		*errp = RET_OK;
		queue = &vmc_qcb[qid];
		disable(ps);
		if (queue->count) {
			msg = queue->item[queue->head];
			if (++queue->head == queue->maxcount)
				queue->head = 0;
			--queue->count;
			restore(ps);
			return msg;
		}
		msg = 0;
		if (queue->tid == NO_TID) {
			queue->tid = vmc_exectid;
			tcbp = &vmc_tasktab[vmc_exectid];
			tcbp->tstate &= ~TBSEXEC;
			tcbp->tstate |= TBSQUEUE;
			vmc_prio_delete((int) vmc_exectid, &vmc_readyhead);
			tcbp->object.queue.qid = qid;
			vmc_sched_disable();
			interrupt_window(ps);
			
			if (timeout != 0) {
				vmc_insertd((int) vmc_exectid, (unsigned long) timeout, ps);
				tcbp->tstate |= TBSDELAY;
				vmc_dlynempty = TRUE;
				vmc_dlytop = get_vmc_dlytop();
			}
			
			/*
			* During the inserrtion, an interrupt could have come in that
			* could have posted the message to the queue and thus could have
			* made the task ready.
			*/
			
			if (!(tcbp->tstate & TBSQUEUE)) {
				if (tcbp->tstate & TBSDELAY) {
					tcbp->tstate &= ~TBSDELAY;
					if ((vmc_dlynempty = vmc_dequeued((int)queue->tid)) != 0)
						vmc_dlytop = get_vmc_dlytop();
				}
				msg = tcbp->object.queue.message;
				if (vmc_readyhead != vmc_exectid)
					vmc_sched_needed = 1;
				vmc_sched_enable();
				restore(ps);
				return ((SYSCALLc *)msg);
			}
			
			if (vmc_readyhead != vmc_exectid)
				vmc_sched_needed = 1;
			vmc_sched_enable();
			if (tcbp->object.queue.qid == qid) {
				*errp = ER_TMO;
				queue->tid = NO_TID;
				tcbp->object.queue.qid = NO_QID;
			}
			else
				msg = tcbp->object.queue.message;
		}
		else
			*errp = ER_PND;
		restore(ps);
		return msg;
	}
	*errp = ER_QID;
	return ((char *) 0);
}

⌨️ 快捷键说明

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