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

📄 anyready.c

📁 基于chord算法的p2p文件系统。A p2p file system based on chord.
💻 C
字号:
/* * Copyright (c) 2003-2005 Russ Cox *                    Massachusetts Institute of Technology *  * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: *  * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. *  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *//* * This is a clumsy and temporary hack.  I need to find a better * way to provide this functionality.  Putting this crap here means * I don't have to taint the thread library with this until I figure out * the right way to do this. * * I apologize for this crappy code.  -rsc */#include <lib9.h>extern "C" {typedef struct Label Label;typedef struct Execargs Execargs;typedef struct Proc Proc;typedef struct Thread Thread;typedef struct Tqueue Tqueue;struct Label{	ulong pc;	ulong bx;	ulong sp;	ulong bp;	ulong si;	ulong di;};struct Execargs{	char		*prog;	char		**args;	int		fd[2];};struct Tqueue		/* Thread queue */{	int		asleep;	Thread	*head;	Thread	**tail;};struct Proc{	Lock		lock;	Label	sched;		/* for context switches */	Proc		*link;		/* in proctab */	int		pid;			/* process id */	int		splhi;		/* delay notes */	Thread	*thread;		/* running thread */	int		needexec;	Execargs	exec;		/* exec argument */	Proc		*newproc;	/* fork argument */	char		exitstr[ERRMAX];	/* exit status */	int		rforkflag;	int		nthreads;	Tqueue	threads;		/* All threads of this proc */	Tqueue	ready;		/* Runnable threads */};struct Thread{	Lock		lock;			/* protects thread data structure */	Label	sched;		/* for context switches */	int		id;			/* thread id */  /* and other stuff... */};extern Proc *_threadgetproc(void);}/* are there any threads ready in the current Proc? */intanyready(){	Proc *p;	p = _threadgetproc();	/* this is only safe because we're not using procs yet */	return p->ready.head != nil;}

⌨️ 快捷键说明

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