pinit.c
来自「TCP-IP红宝书源代码」· C语言 代码 · 共 38 行
C
38 行
/* pinit.c - pinit */
#include <conf.h>
#include <kernel.h>
#include <mark.h>
#include <ports.h>
#ifdef MEMMARK
MARKER ptmark;
#endif
struct ptnode *ptfree; /* list of free queue nodes */
struct pt ports[NPORTS];
int ptnextp;
/*------------------------------------------------------------------------
* pinit -- initialize all ports
*------------------------------------------------------------------------
*/
SYSCALL pinit(maxmsgs)
int maxmsgs;
{
int i;
struct ptnode *next, *prev;
if ( (ptfree=(struct ptnode *) getmem(maxmsgs*sizeof(struct ptnode)))==(struct ptnode *) SYSERR )
panic("pinit - insufficient memory");
for (i=0 ; i<NPORTS ; i++)
ports[i].ptstate = PTFREE;
ptnextp = NPORTS - 1;
/* link up free list of message pointer nodes */
for ( prev=next=ptfree ; --maxmsgs > 0 ; prev=next )
prev->ptnext = ++next;
prev->ptnext = (struct ptnode *)NULL;
return(OK);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?