pinit.c,v
来自「TCP-IP红宝书源代码」· C,V 代码 · 共 62 行
C,V
62 行
head 1.1;
access;
symbols;
locks
dls:1.1; strict;
comment @ * @;
1.1
date 97.09.21.19.29.30; author dls; state Dist;
branches;
next ;
desc
@@
1.1
log
@pre-3e code
@
text
@/* 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 + -
显示快捷键?